fuery
v0.1.1
Published
A pausable function queue with optional parallel concurrency
Downloads
8
Readme
Fuery
A pausable function queue with optional parallel concurrency
Install
$ npm install fuery
Examples
Create a Fuery instance
var Fuery = require('fuery'),
queue = new Fuery();
// Allow only 1 function to run at a time (default is unlimited)
queue.limit = 1;
Queue a function
The first argument is a function that you should call when the function has completed.
queue.add(function(done) {
// Do stuff
done();
});
You can also add your own arguments like this
queue.add(function(done, x, y, z) {
// Do stuff
done();
}, [x, y, z]);
Set context
You can set the context the queued functions run in. When not set, the context defaults to null.
queue.setContext({test: 1});
Start the queue
New Fuery instances are paused upon creation, they always need to be started
queue.start();
Pause the queue
Pausing the queue is also possible, ofcourse. You can supply a callback that will fire when all currently running functions have ended.
queue.pause(function() {
// All running functions are done
});
License
MIT