UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

72 lines (34 loc) 1.03 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [rc-js-util](./rc-js-util.md) &gt; [arrayIndex](./rc-js-util.arrayindex.md) ## arrayIndex() function Populates a `Map` given a key creating function and `ArrayLike`<!-- -->. **Signature:** ```typescript export declare function arrayIndex<TKey, TItem>(items: ArrayLike<TItem>, getKey: (item: TItem, index: number) => TKey | null): Map<Exclude<TKey, null>, TItem>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> items </td><td> ArrayLike&lt;TItem&gt; </td><td> </td></tr> <tr><td> getKey </td><td> (item: TItem, index: number) =&gt; TKey \| null </td><td> </td></tr> </tbody></table> **Returns:** Map&lt;Exclude&lt;TKey, null&gt;, TItem&gt; ## Remarks keys which are null are omitted. See [arrayIndex()](./rc-js-util.arrayindex.md)<!-- -->.