UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

13 lines (10 loc) 370 B
import { flatten } from './flatten.mjs'; import { limitAsync } from './limitAsync.mjs'; async function flatMapAsync(array, callback, options) { if (options?.concurrency != null) { callback = limitAsync(callback, options.concurrency); } const results = await Promise.all(array.map(callback)); return flatten(results); } export { flatMapAsync };