Skip to content

asyncFilter<T>

Filters an array asynchronously, keeping only the elements that satisfy the provided predicate function.

Import:

import { asyncFilter } from 'obsidian-dev-utils/async';

Signature:

function asyncFilter(arr: T[], predicate: (value: T, index: number, array: T[]) => Promisable<boolean>): Promise<T[]>

Parameters:

ParameterTypeDescription
arrT[]The array to filter.
predicate(value: T, index: number, array: T[]) => Promisable<boolean>The predicate function to test each element.

Returns: Promise<T[]> — A Promise that resolves with an array of elements that satisfy the predicate function.