Skip to content

consume

consume(iterable, count?): void

Defined in: packages/core/src/iterable/consume.ts:15

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

The readable form of an empty-bodied for…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).

Iterable<unknown>

The iterable to drain.

number = Number.POSITIVE_INFINITY

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

void

If count is negative, fractional or NaN.