Skip to content

bhsiung/promise-batch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promise-batch

Batch process of list of promises.

batcher(paramList, promiseFunc, size, [debug], [onEachChunkComplete])

parameters

  • paramList: Array of parameters will be passed to promiseFunc.
  • promiseFunc: the promise function.
  • size: size of concurrent thread.
  • debug (optional): it log status when necessary.
  • onEachChunkComplete (optional): Helper function for keep tracking the progress.

Usage

var batcher = require('promise-batch');

batcher([[1,'apple'],[2,'orange'],[3,'grape']],function(num,fruit){
  return promise.resolve(num+1);
},2,false,function(currentIndex,totalCount){
  //optional parameter, used to track status
})
.then(function(results){
  console.log('Everything has been completed!!','and the result has been collected in here -->', results);
})
.catch(function(e){
  // capture exception...
})

TODOs

  • rewrite using es2015
  • maximize the performance, maintain number of cosncurrent threads.

About

Batch process of list of promises.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published