Skip to content

mapChunked

mapChunked<T, R>(items, size, mapper): Promise<R[]>

Defined in: packages/simply-core/src/collection/chunk.ts:59

Map over items in chunks: every item within a chunk is processed concurrently, but one chunk finishes before the next one starts.

Use this to bound concurrency against an org — firing hundreds of describe() calls at once gets you rate-limited, while doing them one at a time is needlessly slow. Chunking gives a fixed-width window without pulling in a queue library.

T

R

readonly T[]

The items to map over.

number

Maximum number of items processed concurrently. Must be at least 1.

(item, index) => Promise<R>

Called once per item, with the item and its index in items.

Promise<R[]>

Every mapper result, in items order (not completion order).

If size is less than 1.