assertMapItem()function
assertMapItem(map: ImmutableMap<K, V>, key: unknown, caller: AnyCaller = assertMapItem): asserts key is K
| Param | Type | |
|---|---|---|
map | ImmutableMap<K, V> | The map to look in. required |
key | unknown | The candidate key to assert. required |
caller | AnyCaller | Function used to attribute a thrown error to the calling site. Defaults to assertMapItem |
| Return | |
|---|---|
asserts key is K | Nothing; narrows key to the map's key type. |
| Throws | |
|---|---|
RequiredError | If key does not exist in map. |
Assert that an unknown value is a key for an item in a map.
Examples
assertMapItem(new Map([["a", 1]]), "a"); // passes