Asynchronously filters an array based on a provided async predicate function.
Executes all predicate calls in parallel using Promise.all, and returns a new array containing only the elements for which the predicate resolves to true.
Promise.all
true
The type of elements in the input array.
The array to filter.
An async function called for each element. Should resolve to true to keep the element.
A promise that resolves to a new array containing the filtered elements.
const isEvenAsync = async (n: number) => n % 2 === 0;await filterAsync([1, 2, 3, 4], isEvenAsync);// → [2, 4] Copy
const isEvenAsync = async (n: number) => n % 2 === 0;await filterAsync([1, 2, 3, 4], isEvenAsync);// → [2, 4]
1.0.0
Asynchronously filters an array based on a provided async predicate function.
Executes all predicate calls in parallel using
Promise.all
, and returns a new array containing only the elements for which the predicate resolves totrue
.