Skip to main content

takeInParallel()

function takeInParallel<T, C>(
collection,
batchSize,
callback,
abortSignal?): AsyncIterable<Awaited<ReturnType<C>>>

Given an iterable collection, returns an async iterable, executing the callback on each batch.

This is useful for batching asynchronous operations.

Type Parameters

Type Parameter
T
C extends (entry) => Promise<any>

Parameters

ParameterTypeDescription
collectionIterable<T, any, any>The collection to batch.
batchSizenumberThe size of each batch.
callbackCThe async callback to execute on each batch.
abortSignal?AbortSignal-

Returns

AsyncIterable<Awaited<ReturnType<C>>>