Class: DefaultMap<K, V>
libs/common/util/DefaultMap.DefaultMap
A map that returns a default value when a key is not found.
Based on https://aaronmoat.com/implementing-pythons-defaultdict-in-javascript/
Type parameters
Name |
---|
K |
V |
Hierarchy
Map
<K
,V
>↳
DefaultMap
Constructors
constructor
• new DefaultMap<K
, V
>(getDefaultValue
)
Type parameters
Name |
---|
K |
V |
Parameters
Name | Type | Description |
---|---|---|
getDefaultValue | (key : K ) => V | A function that returns the default value for a given key |
Overrides
Map<K, V\>.constructor
Defined in
libs/common/util/DefaultMap.ts:10
Methods
get
▸ get(key
): V
Parameters
Name | Type |
---|---|
key | K |
Returns
V
Overrides
Map.get