Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rrainn/asyncfunctionbatch


https://github.com/rrainn/asyncfunctionbatch

Last synced: 23 days ago
JSON representation

Awesome Lists containing this project

README

        

# AsyncFunctionBatch

This package lets you run a batch of async tasks in parallel, while limiting the number of concurrent tasks being run.

## Installation

```bash
npm i --save asyncfunctionbatch
```

## Usage

```js
const {Job} = require("asyncfunctionbatch");

const array = ["hello", "world", "!"];
const concurrency = 10; // max number of tasks to run in parallel
const job = new Job(array, concurrency, async (item) => {
// Run async task, `item` will be the specific array item.
});

await job.run(); // Will resolve after all tasks are done.
```

## License

This package is licensed under the MIT license.