Skip to content

lastAsync

lastAsync<T>(iterable, signal?): Promise<T | undefined>

Defined in: packages/core/src/iterable/async/last.ts:16

Returns the last element, or undefined when the iterable is empty.

The async counterpart of last, without its array fast path: an async source has no length to index into, so the whole of it is drained.

Time complexity: O(n).

T extends DefinedValue

MaybeAsyncIterable<T>

The iterable to read from, sync or async.

AbortSignal

Aborts the drain.

Promise<T | undefined>

The last element, or undefined if there is none.