pairwise.js 650 B

12345678910111213141516171819202122232425
  1. import { Subscriber } from '../Subscriber';
  2. export function pairwise() {
  3. return (source) => source.lift(new PairwiseOperator());
  4. }
  5. class PairwiseOperator {
  6. call(subscriber, source) {
  7. return source.subscribe(new PairwiseSubscriber(subscriber));
  8. }
  9. }
  10. class PairwiseSubscriber extends Subscriber {
  11. constructor(destination) {
  12. super(destination);
  13. this.hasPrev = false;
  14. }
  15. _next(value) {
  16. if (this.hasPrev) {
  17. this.destination.next([this.prev, value]);
  18. }
  19. else {
  20. this.hasPrev = true;
  21. }
  22. this.prev = value;
  23. }
  24. }
  25. //# sourceMappingURL=pairwise.js.map