0.0.4 โข Published 7 months ago
promise-all-batch v0.0.4
๐ Table of Contents
๐ ๏ธ Installation
NOTE: The package is using esm modules!
Install the package locally.
npm i promise-all-batch
โก๏ธ Usage
promiseAllBatch(arr, promiseCallback, size, {
afterEachComplete,
sleepBetween,
});
Basic example that every 1 second will execute 2 numbers in concurrent.
import {promiseAllBatch} from 'promise-all-batch';
const results = await promiseAllBatch(
[1, 2, 3, 4, 5, 6],
(index) => new Promise((resolve) => setTimeout(() => resolve(index), 1000)),
2, // Size of the batch
);
console.log(results); // [1, 2, 3, 4, 5, 6]