source: trip-planner-front/node_modules/rxjs/internal/operators/sequenceEqual.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[6a3a178]1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var Subscriber_1 = require("../Subscriber");
17function sequenceEqual(compareTo, comparator) {
18 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
19}
20exports.sequenceEqual = sequenceEqual;
21var SequenceEqualOperator = (function () {
22 function SequenceEqualOperator(compareTo, comparator) {
23 this.compareTo = compareTo;
24 this.comparator = comparator;
25 }
26 SequenceEqualOperator.prototype.call = function (subscriber, source) {
27 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
28 };
29 return SequenceEqualOperator;
30}());
31exports.SequenceEqualOperator = SequenceEqualOperator;
32var SequenceEqualSubscriber = (function (_super) {
33 __extends(SequenceEqualSubscriber, _super);
34 function SequenceEqualSubscriber(destination, compareTo, comparator) {
35 var _this = _super.call(this, destination) || this;
36 _this.compareTo = compareTo;
37 _this.comparator = comparator;
38 _this._a = [];
39 _this._b = [];
40 _this._oneComplete = false;
41 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
42 return _this;
43 }
44 SequenceEqualSubscriber.prototype._next = function (value) {
45 if (this._oneComplete && this._b.length === 0) {
46 this.emit(false);
47 }
48 else {
49 this._a.push(value);
50 this.checkValues();
51 }
52 };
53 SequenceEqualSubscriber.prototype._complete = function () {
54 if (this._oneComplete) {
55 this.emit(this._a.length === 0 && this._b.length === 0);
56 }
57 else {
58 this._oneComplete = true;
59 }
60 this.unsubscribe();
61 };
62 SequenceEqualSubscriber.prototype.checkValues = function () {
63 var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
64 while (_a.length > 0 && _b.length > 0) {
65 var a = _a.shift();
66 var b = _b.shift();
67 var areEqual = false;
68 try {
69 areEqual = comparator ? comparator(a, b) : a === b;
70 }
71 catch (e) {
72 this.destination.error(e);
73 }
74 if (!areEqual) {
75 this.emit(false);
76 }
77 }
78 };
79 SequenceEqualSubscriber.prototype.emit = function (value) {
80 var destination = this.destination;
81 destination.next(value);
82 destination.complete();
83 };
84 SequenceEqualSubscriber.prototype.nextB = function (value) {
85 if (this._oneComplete && this._a.length === 0) {
86 this.emit(false);
87 }
88 else {
89 this._b.push(value);
90 this.checkValues();
91 }
92 };
93 SequenceEqualSubscriber.prototype.completeB = function () {
94 if (this._oneComplete) {
95 this.emit(this._a.length === 0 && this._b.length === 0);
96 }
97 else {
98 this._oneComplete = true;
99 }
100 };
101 return SequenceEqualSubscriber;
102}(Subscriber_1.Subscriber));
103exports.SequenceEqualSubscriber = SequenceEqualSubscriber;
104var SequenceEqualCompareToSubscriber = (function (_super) {
105 __extends(SequenceEqualCompareToSubscriber, _super);
106 function SequenceEqualCompareToSubscriber(destination, parent) {
107 var _this = _super.call(this, destination) || this;
108 _this.parent = parent;
109 return _this;
110 }
111 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
112 this.parent.nextB(value);
113 };
114 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
115 this.parent.error(err);
116 this.unsubscribe();
117 };
118 SequenceEqualCompareToSubscriber.prototype._complete = function () {
119 this.parent.completeB();
120 this.unsubscribe();
121 };
122 return SequenceEqualCompareToSubscriber;
123}(Subscriber_1.Subscriber));
124//# sourceMappingURL=sequenceEqual.js.map
Note: See TracBrowser for help on using the repository browser.