最新の値と1つ前の値を処理する
const {from} = require('rxjs');
const {pairwise} = require('rxjs/operators');
const numbers$ = from([1, 2, 3, 4, 5]);
numbers$.pipe(pairwise())
.subscribe(
([previous, current]) => console.log([previous, current])
);
出力
[ 1, 2 ]
[ 2, 3 ]
[ 3, 4 ]
[ 4, 5 ]