In memory queue system prioritizing tasks
In memory queue system prioritizing tasks.
$ npm install --save grouped-queue
The constructor take an optionnal array of tasks group. The first
String name will be the first queue to be emptied, the second in second, etc.
By default, the constructor always add a
default queue at the last position. You can overwrite the position of the
default group if you specify it explicitly.
var Queue = require'grouped-queue';var queue = 'first' 'second' 'third' ;
Add a task into a group queue. If no group name is specified,
default will be use.
Implicitly, each time you add a task, the queue will start emptying (if not already running).
Each tasks runned in the queue will receive a callback function to call once finished.
queueaddDBfetchthen cb ;;
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
// This one will eventually runqueueadd method once: "readDB" ;// This one will be dropped as `method` is currently in the queuequeueadd method3 once: "readDB" ;
You can register a task without launching the run loop by passing the argument
queueadd method run: false ;
Bind your tasks with context and arguments!
var/* you get `models` data here! */;queueadd taskbindnull models ;
This event is called each time the queue emptied itself.
Style Guide: Please base yourself on Idiomatic.js style guide with two space indent
Unit test: Unit test are wrote 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
Copyright (c) 2013 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.