onlyAsync
onlyAsync<
T>(iterable,description?,signal?):Promise<T>
Defined in: packages/core/src/iterable/async/only.ts:19
Returns the single element of an iterable, rejecting any other count.
The async counterpart of only. Use oneAsync where an empty iterable is
acceptable.
Time complexity: O(1) — at most two elements are pulled, so this is safe on an endless stream.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”iterable
Section titled “iterable”The iterable to read from, sync or async.
description?
Section titled “description?”string = "item"
What the iterable holds, used in the error message.
signal?
Section titled “signal?”AbortSignal
Aborts the read.
Returns
Section titled “Returns”Promise<T>
The single element.
Throws
Section titled “Throws”If the iterable is empty or holds more than one element.