Skip to content

chouchou900822/map-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

koa/async/await limit map count

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published