nthAsync
nthAsync<
T>(iterable,index,signal?):Promise<T|undefined>
Defined in: packages/core/src/iterable/async/nth.ts:20
Returns the element at index, or undefined when the iterable is shorter
than that.
The async counterpart of nth. Only counts forward; a negative index would
mean buffering the whole tail, so it is rejected.
Time complexity: O(index). The iterator is closed as soon as the element is reached.
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
Parameters
Section titled “Parameters”iterable
Section titled “iterable”The iterable to read from, sync or async.
number
The zero-based position to read. Must be a non-negative integer.
signal?
Section titled “signal?”AbortSignal
Aborts the read.
Returns
Section titled “Returns”Promise<T | undefined>
The element at index, or undefined if there is none.
Throws
Section titled “Throws”If index is not a non-negative integer.