koa-map-limit
v1.1.0
Published
koa/async/await limit map count
Downloads
5
Readme
koa-map-limit
The same as map but runs a maximum of limit operations at the same time use await/yield
Installation
$ npm install koa-map-limit
mapLimit(arr, limit, async callback)
const mapLimit = require('koa-map-limit');
let array = [],
i = 0;
while (i < 100) {
array.push(i);
i++;
}
let reuslt = await mapLimit(array, 10, async (item) => {
return new Promise(function (resolve, reject) {
setTimeout(function () {
console.log(item)
resolve();
}, 1000)
});
});
test
$ npm test