Skip to content

Map

Helper functions that have to do with maps.

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 Parameter
K
V
Parameter Type
map ReadonlyMap<K, V>
predicate (value) => boolean

readonly V[]


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 Parameter
K
V
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.

V | undefined

The first value that satisfies the predicate, or undefined if no values satisfy.