README
ConcurrentArray
Run array higher order functions asynchronously with concurrency control
Installation
npm install --save @sebowy/concurrent-array
# or
yarn add @sebowy/concurrent-array
Usage
Examples
- async sorting
import { ConcurrentArray } from "@sebowy/concurrent-array";
const array = [3, 5, 1, 2, 4];
const asyncArray = new ConcurrentArray(array, {
maxConcurrency: 10,
});
asyncArray
.sort((left, right) => new Promise((resolve) => setTimeout(() => resolve(left - right), 1000)), {
maxConcurrency: 5, // overwrite max concurrency for sort array operation
})
.then(console.log);
will produce:
[1, 2, 3, 4, 5]
respecting allowed maximum concurrency.
Learn more
Please refer to @sebowy/concurrent-queue and @sebowy/async-array README files to learn more about possible options and methods.