0.0.1 • Published 10 years ago
all-limit v0.0.1
all-limit 
Like Promise.all(), but with a concurrency limiter.
About
Promise.all() is great, but sometimes, you want to throttle the number of concurrent executions.
That's where all-limit shines.
Example
'use strict';
import all from 'all-limit';
all({
limit: 3,
list: [ 1, 2, 3, 4, 5, 6, 7, 8 ],
promise(item, resolve, reject) {
// item is a .shift()ed element of the list[]
setTimeout(() => resolve('item: ' + item), 1000);
}
})
.then((results) => console.log('all done:', results))
.catch((err) => console.log('error:', err));all({ limit, list, promise })
limit- Number, the concurrency limiter.list- Array, each element of thelistis provided to thepromisefunction.promise- Function,(item, resolve, reject),itemis an element of thelistarray. Theresolveandrejectarguments are standardPromisecallbacks.
Versions
- 0.0.1 - Initial release
0.0.1
10 years ago