js-util

Home > rc-js-util > arrayFlatMap

arrayFlatMap() function

Iterate over ArrayLike calling a callback against it, the callback returns ArrayLike which is concatenated into a single Array.

Signature:

export declare function arrayFlatMap<TItem, TTransformed>(items: ArrayLike<TItem>, mapCallback: (item: TItem, index: number) => ArrayLike<TTransformed> | null): TTransformed[];

Parameters

Parameter Type Description
items ArrayLike<TItem> The items to iterate over.
mapCallback (item: TItem, index: number) => ArrayLike<TTransformed> | null The return from this callback is concatenated to the result, unless null is returned in which case the result is omitted.

Returns:

TTransformed[]

The output of mapCallback flattened into a single array.

Remarks

See arrayFlatMap().