Skip to main content

concurrentPool

concurrentPool() function

Ensures consistency in the level of concurrency based on the given number of concurrent tasks.

Signature:
declare function concurrentPool<A>(length: number, iterable: AsyncIterable<A>): AsyncIterableIterator<A>;

declare function concurrentPool<A>(length: number, iterable?: AsyncIterable<A>): (iterable: AsyncIterable<A>) => AsyncIterableIterator<A>;

Example

```ts await pipe( [1, 2, 3, 4, 5, 6], toAsync, map((a) => delay(100 * a, a)), concurrentPool(3), each(console.log), // log 1, 2, 3, 4, 5, 6 ); // 2 seconds

Open Source Code