Skip to content

concurrentPool() function

与えられた並行タスク数に基づいて、並行性のレベルの一貫性を保証します。

Signature:

typescript
declare function concurrentPool<A>(
  length: number,
  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
); // 0.9 seconds

Open Source Code

Released under the Apache-2.0 License.