Like Promise.all, but with concurrency.
npm install --save promise-chunkify
import chunkify from "promise-chunkify";
(async () => {
const results = await chunkify([
() => returnsAPromiseWichResolvesTo(1),
() => returnsAPromiseWichResolvedTo(2),
() => returnsAPromiseWichResolvedTo(3)
], { concurrency: 1 });
console.log(results); // [1, 2, 3]
})();
chunkify(factories, options)
Name | Type | Required | Description |
---|---|---|---|
factories | Array | true | Array of factory methods wich returns a promise |
options | Object | false | Chunkify options |
Type: number
Define the concurrency chunk size, if not defined, 0 or negative value,
all promises will apply at once so just use Promise.all([])
instead.
Type: number
Optional timeout (in milliseconds) to delay between each promises chunk
This project is licensed under the MIT License - see the LICENSE file for details