<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]> Maps over items with a bounded number of in-flight promises, preserving
input order.
Fail-fast: when fn rejects, the outer promise rejects with that error and
idle workers stop pulling from the queue (already-in-flight fn calls run
to completion — there's no AbortSignal plumbing). Subsequent rejections
from in-flight calls are swallowed by Promise.all (only the first wins),
so a misbehaving fn can't surface a second error after the function
returns.
items
input array
readonly T[]concurrency
maximum number of concurrent operations
numberfn
mapping function (receives item and index)
(item: T, index: number) => Promise<R>returns
Promise<R[]> array of results in input order