A simple job-queue manager based on Promise mechanims
$ npm install throttle-exec
var ThrottleEngine = require("throttle-exec")
var maximumProcess = 10
var throttleInstance = new ThrottleEngine(maximumProcess)
var wrappedAsync = throttleInstance.wrap(function(p1,p2){
return new Promise(function(resolve,reject){
var ret = {}
// some logic
resolve(ret)
})
})
wrappedAsync("http://npmjs.org","http://google.com").then(function(ret){
console.log(ret)
}).catch(console.error)
var wrappedSync = throttleInstance.wrap(function(p1,p2){
// some logic
return p1 * p2;
})
wrappedSync(5,2).then(function(result){
console.log(result) // 10
}).catch(console.error) // any error will be thrown from try and trigger reject