first
first<
T>(iterable):T|undefined
Defined in: packages/core/src/iterable/first.ts:14
Returns the first element, or undefined when the iterable is empty.
T cannot itself include undefined, so the absent case is never ambiguous.
Use compact first when the source may carry nullish elements.
Time complexity: O(1). The iterator is closed without being drained.
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
The iterable to read from.
Returns
Section titled “Returns”T | undefined
The first element, or undefined if there is none.