@epikodelabs/streamix / src/public-api / slidingPair
Function: slidingPair()
slidingPair<
T>():Operator<T, [T,T|undefined]>
Defined in: projects/libraries/streamix/src/lib/operators/slidingPair.ts:18
Creates a stream operator that emits pairs of values from the source stream, where each pair consists of the current and the previous value.
This operator is a powerful tool for comparing consecutive values in a stream. It maintains an internal state to remember the last value it received. For each new value, it creates a tuple of [current, previous] and emits it to the output stream.
The very first value emitted will have undefined as its "previous" value.
Type Parameters
T
T = any
The type of the values in the source stream.
Returns
Operator<T, [T, T | undefined]>
An Operator instance that can be used in a stream's pipe method, emitting tuples of [T, T | undefined].