grouped-queue

WebJar for grouped-queue

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

grouped-queue
Last Version

Last Version

0.3.3
Release Date

Release Date

Type

Type

jar
Description

Description

grouped-queue
WebJar for grouped-queue
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sboudrias/grouped-queue

Download grouped-queue

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/grouped-queue/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>grouped-queue</artifactId>
    <version>0.3.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/grouped-queue/
implementation 'org.webjars.npm:grouped-queue:0.3.3'
// https://jarcasting.com/artifacts/org.webjars.npm/grouped-queue/
implementation ("org.webjars.npm:grouped-queue:0.3.3")
'org.webjars.npm:grouped-queue:jar:0.3.3'
<dependency org="org.webjars.npm" name="grouped-queue" rev="0.3.3">
  <artifact name="grouped-queue" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='grouped-queue', version='0.3.3')
)
libraryDependencies += "org.webjars.npm" % "grouped-queue" % "0.3.3"
[org.webjars.npm/grouped-queue "0.3.3"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : lodash jar [4.17.2,5)

Project Modules

There are no modules declared in this project.

Grouped Queue Build Status

In memory queue system prioritizing tasks.

Documentation

Installation

$ npm install --save grouped-queue

Methods

Constructor

The constructor takes an optional array of task groups. The first String name will be the first queue to be emptied, the second string will be the second group emptied, etc.

By default, the constructor will always add a default queue in the last position. You can overwrite the position of the default group if you specify it explicitly.

var Queue = require('grouped-queue');

var queue = new Queue([ 'first', 'second', 'third' ]);

Queue#add add( [group], task, [options] )

Add a task into a group queue. If no group name is specified, default will be used.

Implicitly, each time you add a task, the queue will start emptying (if not already running).

Each task function is passed a callback function. This callback must be called when the task is complete.

queue.add(function( cb ) {
  DB.fetch().then( cb );
});

Option: once

You can register tasks in queues that will be dropped if they're already planned. This is done with the once option. You pass a String (basically a name) to the once option.

// This one will eventually run
queue.add( method, { once: "readDB" });

// This one will be dropped as `method` is currently in the queue
queue.add( method3, { once: "readDB" });

Option: run

You can register a task without launching the run loop by passing the argument run: false.

queue.add( method, { run: false });

Pro tip

Bind your tasks with context and arguments!

var task = function( models, cb ) {
  /* you get `models` data here! */
};
queue.add( task.bind(null, models) );

That's all?

Yes!

Events

end

This event is called each time the queue emptied itself.

Contributing

Style Guide: Please base yourself on Idiomatic.js style guide with two space indent
Unit test: Unit tests are written in Mocha. Please add a unit test for every new feature or bug fix. npm test to run the test suite.
Documentation: Add documentation for every API change. Feel free to send corrections or better docs!
Pull Requests: Send fixes PR on the master branch.

License

Copyright (c) 2013 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.

Versions

Version
0.3.3