The same as map but runs a maximum of limit operations at the same time use await/yield
$ 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)
});
});
$ npm test