Map
Helper functions that have to do with maps.
Functions
mapFilter()
function mapFilter<K, V>(map, predicate): readonly V[];
Defined in: functions/map.ts:17
Helper function to get the values in a Map that match an arbitrary condition. Similar to the
Array.map method, but works for maps.
This is efficient such that it avoids converting the map values into an array.
If you want to perform a filter and a map at the same time on an array, use the filterMap
helper function instead.
Type Parameters
| Type Parameter |
|---|
K |
V |
Parameters
| Parameter | Type |
|---|---|
map | ReadonlyMap<K, V> |
predicate | (value) => boolean |
Returns
readonly V[]
mapFind()
function mapFind<K, V>(map, predicate): V | undefined;
Defined in: functions/map.ts:43
Helper function to find a value in a Map. Similar to the Array.find method, but works for
maps.
This is efficient such that it avoids converting the map values into an array.
Type Parameters
| Type Parameter |
|---|
K |
V |
Parameters
| Parameter | Type | Description |
|---|---|---|
map | ReadonlyMap<K, V> | The map to search through. |
predicate | (value, key, map) => boolean | Function that tests each value for a condition. |
Returns
V | undefined
The first value that satisfies the predicate, or undefined if no values satisfy.