Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

pairwise.js 723B

1234567891011121314151617181920212223242526272829
  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. let pair;
  17. if (this.hasPrev) {
  18. pair = [this.prev, value];
  19. }
  20. else {
  21. this.hasPrev = true;
  22. }
  23. this.prev = value;
  24. if (pair) {
  25. this.destination.next(pair);
  26. }
  27. }
  28. }
  29. //# sourceMappingURL=pairwise.js.map