run-each-limit

2.0.0 • Public • Published

NPM version Build Status Dependency Status

run-each-limit

Run an async task for each array element in parallel, but limit the number of tasks executing at the same time.

Install

$ npm install --save run-each-limit

Usage

var eachLimit = require('run-each-limit');

var items = ['a', 'b', 'c', 'd'];
var result = '';

function onItem(item, fn) {
  result += item;
  setTimeout(fn, 200);
}

eachLimit(items, 2, onItem, function(err) {
  console.log(result); // 'abcd'
});

License

MIT © Damian Krzeminski

Package Sidebar

Install

npm i run-each-limit

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

2.58 kB

Total Files

3

Last publish

Collaborators

  • pirxpilot