requireMapItem()function
requireMapItem(map: ImmutableMap<K, T>, key: K, caller: AnyCaller = requireMapItem): T
| Param | Type | |
|---|---|---|
map | ImmutableMap<K, T> | The map to read from. required |
key | K | The key to look up. required |
caller | AnyCaller | 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