Skip to main content

Module: util/map

Functions

getDefault

getDefault<K, V>(map, key, factory): V

Returns value at key in map, creating it using factory if it doesn't exist. Behaves a bit like Python defaultdicts.

Type parameters

Name
K
V

Parameters

NameTypeDescription
mapMap<K, V>The map to check / update
keyKThe key to look for
factory() => VA factory used to construct missing values

Returns

V

The existing value, or the new one if constructed

Defined in

util/map.ts:9