requireFirst()function
requireFirst(items: PossibleArray<T>, caller: AnyCaller = requireFirst): T
| Param | Type | |
|---|---|---|
items | PossibleArray<T> | The array or iterable to read from. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to requireFirst itself). Defaults to requireFirst |
| Return | |
|---|---|
T | The first item. |
| Throws | |
|---|---|
RequiredError | If items is empty. |
Get the first item from an array or iterable.
Examples
requireFirst([1, 2, 3]) // 1