Documentation / @ripl/charts / createKeyedLookup
Function: createKeyedLookup() ​
createKeyedLookup<
TValue,TKey>(values,getKey): (key) =>TValue|undefined
Defined in: charts/src/core/data.ts:83
Builds a key → value lookup with Array.prototype.find semantics over a key comparison: the earliest match wins for a duplicated key, and an unknown key resolves to undefined.
Type Parameters ​
| Type Parameter | Description |
|---|---|
TValue | The array's element type. |
TKey | The key type the values are looked up by. |
Parameters ​
| Parameter | Type | Description |
|---|---|---|
values | readonly TValue[] | The array to index, in order. |
getKey | (value) => TKey | Resolves a value's lookup key. |
Returns ​
A function resolving a key to its first matching value, or undefined when absent.
(key) => TValue | undefined