https://github.com/pirxpilot/run-each-limit
Run an async task for each array element in parallel, but limit the number of tasks executing at the same time.
https://github.com/pirxpilot/run-each-limit
Last synced: over 1 year ago
JSON representation
Run an async task for each array element in parallel, but limit the number of tasks executing at the same time.
- Host: GitHub
- URL: https://github.com/pirxpilot/run-each-limit
- Owner: pirxpilot
- Created: 2017-05-13T17:20:15.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T21:15:56.000Z (over 2 years ago)
- Last Synced: 2025-03-03T05:36:20.767Z (over 1 year ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]
# 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
```sh
$ npm install --save run-each-limit
```
## Usage
```js
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](https://pirxpilot.me)
[npm-image]: https://img.shields.io/npm/v/run-each-limit
[npm-url]: https://npmjs.org/package/run-each-limit
[build-url]: https://github.com/pirxpilot/run-each-limit/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/run-each-limit/check.yaml?branch=main
[deps-image]: https://img.shields.io/librariesio/release/npm/run-each-limit
[deps-url]: https://libraries.io/npm/run-each-limit