es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
17 lines (12 loc) • 490 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const flatten = require('./flatten.js');
const limitAsync = require('./limitAsync.js');
async function flatMapAsync(array, callback, options) {
if (options?.concurrency != null) {
callback = limitAsync.limitAsync(callback, options.concurrency);
}
const results = await Promise.all(array.map(callback));
return flatten.flatten(results);
}
exports.flatMapAsync = flatMapAsync;