requireMapItem()function

requireMapItem(map: ImmutableMap<K, T>, key: K, caller: AnyCaller = requireMapItem): T
ParamType
mapImmutableMap<K, T>
The map to read from. required
keyK
The key to look up. required
callerAnyCaller
Function used to attribute a thrown error to the calling site. Defaults to requireMapItem
Return
T
The value for key.
Throws
RequiredError
If key does not exist in map.

Get an item in a map, or throw RequiredError if it doesn't exist.

Examples

requireMapItem(new Map([["a", 1]]), "a") // 1