worq
v2.1.2
Published
Promising job queue
Downloads
28
Maintainers
Readme
worq
Promising job queue
Run promises in series or with a configurable concurrency limit
Install
$ npm install --save worq
Usage
const Queue = require('worq');
let queue = new Queue();
queue.run([
() => somePromisingFunction(),
() => someOtherPromisingFunction(),
() => someNormalFunction()
// these functions will be executed in series
]).then(results => {
// results will be an array containing the return / fulfillment values
});
API
Queue([options])
options
concurrency
Type: number
Default: 1
The maximum number of jobs that can run simultaneously
Queue.run(jobs)
jobs
Type: Function[]
An array of jobs. Jobs may return/throw regularly or return a promise.
Returns a promise for an array containing the fulfillment values in the same order.
Queue.cancel()
Cancels the remaining jobs.
License
MIT © JM Versteeg