UNPKG

es-toolkit

Version:

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

12 lines (9 loc) 357 B
import { limitAsync } from './limitAsync.mjs'; async function filterAsync(array, predicate, options) { if (options?.concurrency != null) { predicate = limitAsync(predicate, options.concurrency); } const results = await Promise.all(array.map(predicate)); return array.filter((_, index) => results[index]); } export { filterAsync };