js-util

Home > rc-js-util > arrayIndex

arrayIndex() function

Populates a Map given a key creating function and ArrayLike.

Signature:

export declare function arrayIndex<TKey, TItem>(items: ArrayLike<TItem>, getKey: (item: TItem, index: number) => TKey | null): Map<Exclude<TKey, null>, TItem>;

Parameters

Parameter Type Description
items ArrayLike<TItem>  
getKey (item: TItem, index: number) => TKey | null  

Returns:

Map<Exclude<TKey, null>, TItem>

Remarks

keys which are null are omitted.

See arrayIndex().