Count items

library operator
ID: 5df619e7-f8ab-44d9-b315-05fdcd52ee43
Counts number of items in a stream of generic items.

Behavior

Test data showing the behavior of Count items

Count items

It counts the number of items in a stream.

Input Output
[1,"b",false,null] 4
[1,2,3,4,5] 5
["a","b","abc"] 3
Zero if empty

It emits 0 for empty streams.

Input Output
[] 0

Implementation

The implementation of Count items makes use of the following 3 operators.

1
Add
Adds two numbers A and B and emits their sum.
1
Emits a constant value for each item.
1
Reduces the items of a stream pairwise using a reducer delegate.

Used in

The Count items operator is used by 2 operators.

Emits the median number of a stream of numbers.
Emits the average of a stream of numbers.