ordered-queue

Queue with concurrency that starts tasks in order and runs them in parallel.

ordered-queue

Queue with concurrency that starts tasks in order and runs them in parallel.

Usage

var OrderedQueue = require('ordered-queue');
var concurrency = 5;
var q = new OrderedQueue(function worker(strcallback) {
  console.log(str);
  callback();
}, concurrency);
 
q.push(3, 'fox');
q.push(1, 'quick');
q.push(0, 'the');
q.push(2, 'brown');
 
// Will print: 
// 
// the 
// quick 
// brown 
// fox 
// 

API

Creates a new ordered queue with given worker and concurrency.

order must be an integer that determines the order of the task. The callback is optional, will be called once task finishes if provided. All arguments inbetween will be passed to the worker.

Kills the queue.

Events

  • Error

Emitted when there is an error processing a task and a callback isn't given to the push method.

Queue is full.

Queue is empty, with tasks still running.

Queue is empty and last task has finished.

Install

npm install ordered-queue

Tests

Tests are written with mocha

npm test

License

MIT