1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/** PURE_IMPORTS_START tslib,_Subscriber,_util_tryCatch,_util_errorObject PURE_IMPORTS_END */
import * as tslib_1 from "tslib";
import { Subscriber } from '../Subscriber';
import { tryCatch } from '../util/tryCatch';
import { errorObject } from '../util/errorObject';
export function sequenceEqual(compareTo, comparor) {
return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
}
var SequenceEqualOperator = /*@__PURE__*/ (function () {
function SequenceEqualOperator(compareTo, comparor) {
this.compareTo = compareTo;
this.comparor = comparor;
}
SequenceEqualOperator.prototype.call = function (subscriber, source) {
return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
};
return SequenceEqualOperator;
}());
export { SequenceEqualOperator };
var SequenceEqualSubscriber = /*@__PURE__*/ (function (_super) {
tslib_1.__extends(SequenceEqualSubscriber, _super);
function SequenceEqualSubscriber(destination, compareTo, comparor) {
var _this = _super.call(this, destination) || this;
_this.compareTo = compareTo;
_this.comparor = comparor;
_this._a = [];
_this._b = [];
_this._oneComplete = false;
_this.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
return _this;
}
SequenceEqualSubscriber.prototype._next = function (value) {
if (this._oneComplete && this._b.length === 0) {
this.emit(false);
}
else {
this._a.push(value);
this.checkValues();
}
};
SequenceEqualSubscriber.prototype._complete = function () {
if (this._oneComplete) {
this.emit(this._a.length === 0 && this._b.length === 0);
}
else {
this._oneComplete = true;
}
};
SequenceEqualSubscriber.prototype.checkValues = function () {
var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
while (_a.length > 0 && _b.length > 0) {
var a = _a.shift();
var b = _b.shift();
var areEqual = false;
if (comparor) {
areEqual = tryCatch(comparor)(a, b);
if (areEqual === errorObject) {
this.destination.error(errorObject.e);
}
}
else {
areEqual = a === b;
}
if (!areEqual) {
this.emit(false);
}
}
};
SequenceEqualSubscriber.prototype.emit = function (value) {
var destination = this.destination;
destination.next(value);
destination.complete();
};
SequenceEqualSubscriber.prototype.nextB = function (value) {
if (this._oneComplete && this._a.length === 0) {
this.emit(false);
}
else {
this._b.push(value);
this.checkValues();
}
};
return SequenceEqualSubscriber;
}(Subscriber));
export { SequenceEqualSubscriber };
var SequenceEqualCompareToSubscriber = /*@__PURE__*/ (function (_super) {
tslib_1.__extends(SequenceEqualCompareToSubscriber, _super);
function SequenceEqualCompareToSubscriber(destination, parent) {
var _this = _super.call(this, destination) || this;
_this.parent = parent;
return _this;
}
SequenceEqualCompareToSubscriber.prototype._next = function (value) {
this.parent.nextB(value);
};
SequenceEqualCompareToSubscriber.prototype._error = function (err) {
this.parent.error(err);
};
SequenceEqualCompareToSubscriber.prototype._complete = function () {
this.parent._complete();
};
return SequenceEqualCompareToSubscriber;
}(Subscriber));
//# sourceMappingURL=sequenceEqual.js.map
|