forEachAsync es-toolkit
Executes an async function for each element in an array.
Reference
forEachAsync(array, callback, options?)
Use forEachAsync to perform async operations with side effects for each element in an array. Unlike regular forEach, it returns a promise that resolves when all async operations complete.
The concurrency option allows you to limit concurrent executions to control load on servers or databases. It's useful for operations that don't return values, like logging, file uploads, or database updates.
Parameters
The array to iterate over.
An async function to execute for each element.
Options to control concurrency.
concurrency(number, optional): Maximum number of concurrent operations. If not specified, all operations run concurrently.
Returns
A promise that resolves when all operations complete.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.