wishthis/node_modules/rxjs/_esm2015/internal/operators/pairwise.js
2022-05-29 11:24:36 +02:00

29 lines
No EOL
723 B
JavaScript

import { Subscriber } from '../Subscriber';
export function pairwise() {
return (source) => source.lift(new PairwiseOperator());
}
class PairwiseOperator {
call(subscriber, source) {
return source.subscribe(new PairwiseSubscriber(subscriber));
}
}
class PairwiseSubscriber extends Subscriber {
constructor(destination) {
super(destination);
this.hasPrev = false;
}
_next(value) {
let pair;
if (this.hasPrev) {
pair = [this.prev, value];
}
else {
this.hasPrev = true;
}
this.prev = value;
if (pair) {
this.destination.next(pair);
}
}
}
//# sourceMappingURL=pairwise.js.map