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
| Name | Type | Description |
|---|---|---|
map | Map<K, V> | The map to check / update |
key | K | The key to look for |
factory | () => V | A factory used to construct missing values |
Returns
V
The existing value, or the new one if constructed
Defined in
util/map.ts:9