mapSettled
Like mapAsync, but never rejects: each item gets its own result, in the shape of
Promise.allSettled, so one failure does not stop or hide the others.
Promise.allSettled(array.map(fn)) does the same without a concurrency cap; parallelSettle
caps it but splits the results into two lists and loses which item failed. This keeps both:
the cap, and one result per item in input order.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | The array to map over |
fn | function | Async (or sync) function called with `(item, index)`; a throw counts as a rejection |
options | number | AsyncArrayOptions | Maximum number of concurrent calls (defaults to unlimited), or the options with a `signal` to stop — see AsyncArrayOptions. An abort is not an outcome: it rejects the whole call with the signal’s reason. (optional) |
Returns
Section titled “Returns”Promise<PromiseSettledResult<Awaited<R>>[]> — One PromiseSettledResult per item, in input order
Examples
Section titled “Examples”Keep going when some calls fail
Section titled “Keep going when some calls fail”Each item gets its own result, like Promise.allSettled.
Cap concurrency
Section titled “Cap concurrency”The third argument limits how many calls run at once.
Related Types
Section titled “Related Types”AsyncArrayOptions
Section titled “AsyncArrayOptions”Options for mapAsync, mapSettled, filterAsync and forEachAsync.
