Async batch with concurrency control and progress reporting for nodejs and the browser
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples add result example Mar 13, 2013
test tests: use after to sync callbacks Nov 21, 2017
.gitignore Initial commit Jan 17, 2012
.npmignore Initial commit Jan 17, 2012
History.md Release 0.6.1 May 16, 2017
LICENSE docs: move license to LICENSE file Mar 11, 2017
Readme.md docs: add badges Nov 20, 2017
component.json Release 0.6.1 May 16, 2017
index.js Fix process.nextTick detection in Node.js May 16, 2017
package.json build: add package keywords Nov 21, 2017

Readme.md

batch

NPM Version NPM Downloads

Simple async batch with concurrency control and progress reporting.

Installation

$ npm install batch

API

var Batch = require('batch')
  , batch = new Batch;

batch.concurrency(4);

ids.forEach(function(id){
  batch.push(function(done){
    User.get(id, done);
  });
});

batch.on('progress', function(e){

});

batch.end(function(err, users){

});

Progress events

Contain the "job" index, response value, duration information, and completion data.

{ index: 1,
  value: 'bar',
  pending: 2,
  total: 3,
  complete: 2,
  percent: 66,
  start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  duration: 0 }

License

MIT