Skip to content

@epikodelabs/streamix


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

Function: max()

max<T>(comparator?): Operator<T, T>

Defined in: projects/libraries/streamix/aggregates/src/lib/operators/max.ts:17

Creates a stream operator that emits the maximum value from the source stream.

This terminal operator consumes every downstream value, retains the current maximum as data flows through, and waits for the source to complete before emitting the winner. A comparator can be provided to override the default > comparison; asynchronous comparators are supported because they are awaited internally. The operator emits once with the maximum value (if any values were provided) and then completes. For empty sources it returns DONE without emitting.

Type Parameters

T

T = any

The type of the values in the source stream.

Parameters

comparator?

(a, b) => MaybePromise<number>

Optional comparison function: positive if a > b, negative if a < b.

Returns

Operator<T, T>

An Operator instance usable in a stream's pipe method.

Released under the GNU AGPL v3 or later.