Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
731 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 |
|
---|
| 2 | # batch
|
---|
| 3 |
|
---|
| 4 | Simple async batch with concurrency control and progress reporting.
|
---|
| 5 |
|
---|
| 6 | ## Installation
|
---|
| 7 |
|
---|
| 8 | ```
|
---|
| 9 | $ npm install batch
|
---|
| 10 | ```
|
---|
| 11 |
|
---|
| 12 | ## API
|
---|
| 13 |
|
---|
| 14 | ```js
|
---|
| 15 | var Batch = require('batch')
|
---|
| 16 | , batch = new Batch;
|
---|
| 17 |
|
---|
| 18 | batch.concurrency(4);
|
---|
| 19 |
|
---|
| 20 | ids.forEach(function(id){
|
---|
| 21 | batch.push(function(done){
|
---|
| 22 | User.get(id, done);
|
---|
| 23 | });
|
---|
| 24 | });
|
---|
| 25 |
|
---|
| 26 | batch.on('progress', function(e){
|
---|
| 27 |
|
---|
| 28 | });
|
---|
| 29 |
|
---|
| 30 | batch.end(function(err, users){
|
---|
| 31 |
|
---|
| 32 | });
|
---|
| 33 | ```
|
---|
| 34 |
|
---|
| 35 | ### Progress events
|
---|
| 36 |
|
---|
| 37 | Contain the "job" index, response value, duration information, and completion data.
|
---|
| 38 |
|
---|
| 39 | ```
|
---|
| 40 | { index: 1,
|
---|
| 41 | value: 'bar',
|
---|
| 42 | pending: 2,
|
---|
| 43 | total: 3,
|
---|
| 44 | complete: 2,
|
---|
| 45 | percent: 66,
|
---|
| 46 | start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
|
---|
| 47 | end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
|
---|
| 48 | duration: 0 }
|
---|
| 49 | ```
|
---|
| 50 |
|
---|
| 51 | ## License
|
---|
| 52 |
|
---|
| 53 | [MIT](LICENSE)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.