requireFirst()function

requireFirst(items: PossibleArray<T>, caller: AnyCaller = requireFirst): T
ParamType
itemsPossibleArray<T>
The array or iterable to read from. required
callerAnyCaller
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