requireDictionaryItem()function
requireDictionaryItem(dict: ImmutableDictionary<T>, key: string, caller: AnyCaller = requireDictionaryItem): T
| Param | Type | |
|---|---|---|
dict | ImmutableDictionary<T> | The dictionary to read the item from. required |
key | string | The key of the item to read. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to requireDictionaryItem itself). Defaults to requireDictionaryItem |
| Return | |
|---|---|
T | The value of the item. |
| Throws | |
|---|---|
RequiredError | If key is not an own prop of dict. |
Get an item in a dictionary object, or throw RequiredError if it doesn't exist.
Examples
requireDictionaryItem({ a: 1 }, "a"); // 1