batch

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

Github星跟踪图

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

主要指标

概览
名称与所有者visionmedia/batch
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2012-02-13 08:47:37
推送于2024-09-04 06:16:04
最后一次提交2022-10-02 13:55:16
发布数16
最新版本名称0.6.1 (发布于 2017-05-17 05:10:58)
第一版名称0.0.2 (发布于 )
用户参与
星数320
关注者数4
派生数52
提交数261
已启用问题?
问题数16
打开的问题数2
拉请求数13
打开的拉请求数1
关闭的拉请求数14
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?