function pooledMap
pooledMap<T, R>(): AsyncIterableIterator<R>pooledMap transforms values from an (async) iterable into another async iterable. The transforms are done concurrently, with a max concurrency defined by the poolLimit.
If an error is thrown from iterableFn, no new transformations will begin.
All currently executing transformations are allowed to finish and still
yielded on success. After that, the rejections among them are gathered and
thrown by the iterator in an AggregateError.
Examples
Usage
Usage
import { pooledMap } from "@std/async/pool"; import { assertEquals } from "@std/assert"; const results = pooledMap( 2, [1, 2, 3], (i) => new Promise((r) => setTimeout(() => r(i), 1000)), ); assertEquals(await Array.fromAsync(results), [1, 2, 3]);
Type Parameters
Tthe input type.
Rthe output type.
Parameters
Return Type
AsyncIterableIterator<R>The async iterator with the transformed values.
Throws
RangeErrorIf poolLimit is not a positive integer.