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
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [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<TItem>
</td><td>
</td></tr>
<tr><td>
getKey
</td><td>
(item: TItem, index: number) => TKey \| null
</td><td>
</td></tr>
</tbody></table>
**Returns:**
Map<Exclude<TKey, null>, TItem>
## Remarks
keys which are null are omitted.
See [arrayIndex()](./rc-js-util.arrayindex.md)<!-- -->.