You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
723 B

4 years ago
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