Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / aggregates/src/public-api / mode

Function: mode()

mode<T, K>(keySelector?): Operator<T, T[]>

Defined in: projects/libraries/streamix/aggregates/src/lib/operators/mode.ts:16

Emits the most frequently occurring value(s) sampled from the source stream.

Values are keyed (optionally via keySelector) and counted as the stream flows through. After the source completes, the operator emits all values whose count matches the maximum frequency. Empty streams result in DONE without emission.

Type Parameters

T

T = any

The type of values emitted downstream.

K

K = any

The type of the key used for tracking counts.

Parameters

keySelector?

(value) => MaybePromise<K>

Optional function that derives a key from each value; it may return a promise. If omitted, the values themselves act as keys.

Returns

Operator<T, T[]>

An Operator instance that emits an array of the most-frequent items before completing.

Released under the GNU AGPL v3 or later.