batch

为 nodejs 和浏览器提供具有并发控制和进度报告功能的异步批处理功能。「Async batch with concurrency control and progress reporting for nodejs and the browser」

  • Owner: visionmedia/batch
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

batch

NPM Version
NPM Downloads
Build Status
Test Coverage

Simple async batch with concurrency control and progress reporting.

Installation

This is a Node.js module available through the
npm registry. Installation is done using the
npm install command:

$ npm install batch

Usage

var Batch = require('batch')

new Batch([...fns])

Create a new Batch.

batch.concurrency(n)

Set concurrency to n.

batch.end([cb])

Execute all queued functions in parallel, executing cb(err, results).

batch.push(fn)

Queue a function.

batch.throws(throws)

Set wether Batch will or will not throw up.

progress event

Contains 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 }

Example

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){

});

License

MIT

Main metrics

Overview
Name With Ownervisionmedia/batch
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-02-13 00:47:37
Pushed At2024-09-03 22:16:04
Last Commit At2022-10-02 01:55:16
Release Count16
Last Release Name0.6.1 (Posted on 2017-05-16 17:10:58)
First Release Name0.0.2 (Posted on )
用户参与
Stargazers Count320
Watchers Count6
Fork Count52
Commits Count261
Has Issues Enabled
Issues Count16
Issue Open Count2
Pull Requests Count13
Pull Requests Open Count1
Pull Requests Close Count14
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private