BACK
Referencepairwise
Reference · 11

pairwise

Emits pairs of [previous, current].

Signature

pairwise(): OperatorFunction

Marble diagram

in:       --1--2--3--4--|
pairwise:    --[1,2]-[2,3]-[3,4]-|

What it does

Remembers the last value and, on the next one, emits the pair [previous, current]. It emits nothing until the second next.

When to use

A delta between values: scroll difference, price change, cursor direction. Any logic where "current versus previous" makes sense.

See also

scan, bufferCount, distinctUntilChanged

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