koa-map-limit

1.1.0 • Public • Published

koa-map-limit

Build Status

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

中文

用 await/yield 的时候控制并发数量

Readme

Keywords

Package Sidebar

Install

npm i koa-map-limit

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

2.65 kB

Total Files

5

Last publish

Collaborators

  • edisonguo