Skip to content

asyncFlatMap<T, U>

Maps over an array asynchronously, applying the provided callback function to each element, and then flattens the results into a single array.

Import:

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

Signature:

function asyncFlatMap(arr: T[], callback: (value: T, index: number, array: T[]) => Promisable<U[]>): Promise<U[]>

Parameters:

ParameterTypeDescription
arrT[]The array to map over and flatten.
callback(value: T, index: number, array: T[]) => Promisable<U[]>The callback function to apply to each element.

Returns: Promise<U[]> — A Promise that resolves with a flattened array of the results of the callback function.