batch

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

  • 所有者: visionmedia/batch
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

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 00:47:37
推送於2024-09-03 22:16:04
最后一次提交2022-10-02 01:55:16
發布數16
最新版本名稱0.6.1 (發布於 2017-05-16 17:10:58)
第一版名稱0.0.2 (發布於 )
用户参与
星數320
關注者數6
派生數52
提交數261
已啟用問題?
問題數16
打開的問題數2
拉請求數13
打開的拉請求數1
關閉的拉請求數14
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?