forEachAsync
The async counterpart to Array.prototype.forEach: runs fn for every item for its
side effects, discarding any return value. Prefer mapAsync when you need the
results — this only exists to signal that intent clearly, same as the sync
forEach/map pair.
Available since v3.0.4
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | The array to iterate |
fn | function | Async (or sync) function called with `(item, index)` |
options | number | AsyncArrayOptions | Maximum number of concurrent calls (defaults to unlimited), or the options with a `signal` to stop — see AsyncArrayOptions (optional) |
Returns
Section titled “Returns”Promise<void> — A promise that resolves once every call has settled
Examples
Section titled “Examples”Upload files with a concurrency cap
Section titled “Upload files with a concurrency cap”Runs fn for its side effects only; at most concurrency calls at once.
Related Types
Section titled “Related Types”AsyncArrayOptions
Section titled “AsyncArrayOptions”Options for mapAsync, mapSettled, filterAsync and forEachAsync.
