You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
731 B

4 years ago
  1. # batch
  2. Simple async batch with concurrency control and progress reporting.
  3. ## Installation
  4. ```
  5. $ npm install batch
  6. ```
  7. ## API
  8. ```js
  9. var Batch = require('batch')
  10. , batch = new Batch;
  11. batch.concurrency(4);
  12. ids.forEach(function(id){
  13. batch.push(function(done){
  14. User.get(id, done);
  15. });
  16. });
  17. batch.on('progress', function(e){
  18. });
  19. batch.end(function(err, users){
  20. });
  21. ```
  22. ### Progress events
  23. Contain the "job" index, response value, duration information, and completion data.
  24. ```
  25. { index: 1,
  26. value: 'bar',
  27. pending: 2,
  28. total: 3,
  29. complete: 2,
  30. percent: 66,
  31. start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  32. end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  33. duration: 0 }
  34. ```
  35. ## License
  36. [MIT](LICENSE)