Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm2015 / internal / operators / sequenceEqual.js
1 import { Subscriber } from '../Subscriber';
2 export function sequenceEqual(compareTo, comparator) {
3     return (source) => source.lift(new SequenceEqualOperator(compareTo, comparator));
4 }
5 export class SequenceEqualOperator {
6     constructor(compareTo, comparator) {
7         this.compareTo = compareTo;
8         this.comparator = comparator;
9     }
10     call(subscriber, source) {
11         return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
12     }
13 }
14 export class SequenceEqualSubscriber extends Subscriber {
15     constructor(destination, compareTo, comparator) {
16         super(destination);
17         this.compareTo = compareTo;
18         this.comparator = comparator;
19         this._a = [];
20         this._b = [];
21         this._oneComplete = false;
22         this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, this)));
23     }
24     _next(value) {
25         if (this._oneComplete && this._b.length === 0) {
26             this.emit(false);
27         }
28         else {
29             this._a.push(value);
30             this.checkValues();
31         }
32     }
33     _complete() {
34         if (this._oneComplete) {
35             this.emit(this._a.length === 0 && this._b.length === 0);
36         }
37         else {
38             this._oneComplete = true;
39         }
40         this.unsubscribe();
41     }
42     checkValues() {
43         const { _a, _b, comparator } = this;
44         while (_a.length > 0 && _b.length > 0) {
45             let a = _a.shift();
46             let b = _b.shift();
47             let areEqual = false;
48             try {
49                 areEqual = comparator ? comparator(a, b) : a === b;
50             }
51             catch (e) {
52                 this.destination.error(e);
53             }
54             if (!areEqual) {
55                 this.emit(false);
56             }
57         }
58     }
59     emit(value) {
60         const { destination } = this;
61         destination.next(value);
62         destination.complete();
63     }
64     nextB(value) {
65         if (this._oneComplete && this._a.length === 0) {
66             this.emit(false);
67         }
68         else {
69             this._b.push(value);
70             this.checkValues();
71         }
72     }
73     completeB() {
74         if (this._oneComplete) {
75             this.emit(this._a.length === 0 && this._b.length === 0);
76         }
77         else {
78             this._oneComplete = true;
79         }
80     }
81 }
82 class SequenceEqualCompareToSubscriber extends Subscriber {
83     constructor(destination, parent) {
84         super(destination);
85         this.parent = parent;
86     }
87     _next(value) {
88         this.parent.nextB(value);
89     }
90     _error(err) {
91         this.parent.error(err);
92         this.unsubscribe();
93     }
94     _complete() {
95         this.parent.completeB();
96         this.unsubscribe();
97     }
98 }
99 //# sourceMappingURL=sequenceEqual.js.map