Skip to content

count

count(iterable): number

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

Counts the elements of an iterable, consuming it.

Named for what it returns rather than length, which would promise O(1).

Time complexity: O(1) for an Array, Set or Map, which already know their own size; O(n) for anything else, which has to be drained.

Iterable<unknown>

The iterable to count.

number

How many elements it yielded.