Skip to content

consumeAsync

consumeAsync(iterable, count?, signal?): Promise<void>

Defined in: packages/core/src/iterable/async/consume.ts:20

Drains an iterable without materialising it, for a pipeline whose side effects are the point.

The async counterpart of consume, and the readable form of an empty-bodied for await…of, which reads like a mistake. The iterator is closed when a count cuts the drain short.

Time complexity: O(min(n, count)). Memory: O(1).

MaybeAsyncIterable<unknown>

The iterable to drain, sync or async.

number = Number.POSITIVE_INFINITY

How many elements to pull. Must be a non-negative integer or Infinity, the default, which drains to the end.

AbortSignal

Aborts the drain.

Promise<void>

If count is negative, fractional or NaN.