0.0.4 โ€ข Published 7 months ago

promise-all-batch v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

๐Ÿ“– 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]

๐Ÿ“œ License

MIT

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago