Constructor
new CanonMap(entries?, canonizer?)
Initialize a CanonMap.
Parameters:
Name | Type | Description |
---|---|---|
entries? |
Iterable | An iterable yielding all key-value tuples that will be fed into the Map. Without this, the Map is initialized to empty. |
canonizer? |
Canonizer | number | Function to map keys to suitable primitives. If not provided, the CanonMap will use a default canonizer. If a number is provided, that number will be the recursion depth of the default canonizer, overriding the default depth of 2. |
Extends
- Map
Methods
delete(key)
Delete the key-value pair associated with the canonized key
.
Does nothing if that entry is not present.
Parameters:
Name | Type | Description |
---|---|---|
key |
K | The key to delete the canonization of. |
Returns:
true
if an element in the CanonMap object existed and has been removed, false
if the element does not exist.
get(key) → {T|undefined}
Get the value at the canonized key in the CanonMap object. Returns the CanonMap object.
Parameters:
Name | Type | Description |
---|---|---|
key |
K | The key to look up. |
Returns:
The value if found, undefined
otherwise.
- Type
- T | undefined
has(key) → {boolean}
Get the value at the canonized key in the CanonMap object. Returns the CanonMap object.
Parameters:
Name | Type | Description |
---|---|---|
key |
K | The key to look up. |
Returns:
true
if the canonization of the key is present in the CanonMap, false
otherwise.
- Type
- boolean
set(key, val)
Set the value for the canonized key in the CanonMap object. Returns the CanonMap object.
Parameters:
Name | Type | Description |
---|---|---|
key |
K | The key to set. |
val |
T | The value to set at that key. |