assertMapItem()function

assertMapItem(map: ImmutableMap<K, V>, key: unknown, caller: AnyCaller = assertMapItem): asserts key is K
ParamType
mapImmutableMap<K, V>
The map to look in. required
keyunknown
The candidate key to assert. required
callerAnyCaller
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