BACK
Referencecount
Reference · 52

count

Counts the values and emits the number on completion.

Signature

count(predicate?: (value: T, index: number) => boolean): OperatorFunction

What it does

It doesn't pass the source values on. Instead it increments a counter and, after complete, emits the final number.

When to use

Counting items after a filter, validating a result count, simple aggregates over finite streams.

See also

reduce, toArray, isEmpty

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...