1.1.0 • Published 6 years ago

koa-map-limit v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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 的时候控制并发数量

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago