UNPKG

es-toolkit

Version:

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

16 lines (11 loc) 468 B
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const limitAsync = require('./limitAsync.js'); async function filterAsync(array, predicate, options) { if (options?.concurrency != null) { predicate = limitAsync.limitAsync(predicate, options.concurrency); } const results = await Promise.all(array.map(predicate)); return array.filter((_, index) => results[index]); } exports.filterAsync = filterAsync;