Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / mergeScan.js
1 /** PURE_IMPORTS_START tslib,_util_subscribeToResult,_OuterSubscriber,_InnerSubscriber PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { subscribeToResult } from '../util/subscribeToResult';
4 import { OuterSubscriber } from '../OuterSubscriber';
5 import { InnerSubscriber } from '../InnerSubscriber';
6 export function mergeScan(accumulator, seed, concurrent) {
7     if (concurrent === void 0) {
8         concurrent = Number.POSITIVE_INFINITY;
9     }
10     return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
11 }
12 var MergeScanOperator = /*@__PURE__*/ (function () {
13     function MergeScanOperator(accumulator, seed, concurrent) {
14         this.accumulator = accumulator;
15         this.seed = seed;
16         this.concurrent = concurrent;
17     }
18     MergeScanOperator.prototype.call = function (subscriber, source) {
19         return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
20     };
21     return MergeScanOperator;
22 }());
23 export { MergeScanOperator };
24 var MergeScanSubscriber = /*@__PURE__*/ (function (_super) {
25     tslib_1.__extends(MergeScanSubscriber, _super);
26     function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
27         var _this = _super.call(this, destination) || this;
28         _this.accumulator = accumulator;
29         _this.acc = acc;
30         _this.concurrent = concurrent;
31         _this.hasValue = false;
32         _this.hasCompleted = false;
33         _this.buffer = [];
34         _this.active = 0;
35         _this.index = 0;
36         return _this;
37     }
38     MergeScanSubscriber.prototype._next = function (value) {
39         if (this.active < this.concurrent) {
40             var index = this.index++;
41             var destination = this.destination;
42             var ish = void 0;
43             try {
44                 var accumulator = this.accumulator;
45                 ish = accumulator(this.acc, value, index);
46             }
47             catch (e) {
48                 return destination.error(e);
49             }
50             this.active++;
51             this._innerSub(ish, value, index);
52         }
53         else {
54             this.buffer.push(value);
55         }
56     };
57     MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
58         var innerSubscriber = new InnerSubscriber(this, value, index);
59         var destination = this.destination;
60         destination.add(innerSubscriber);
61         var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
62         if (innerSubscription !== innerSubscriber) {
63             destination.add(innerSubscription);
64         }
65     };
66     MergeScanSubscriber.prototype._complete = function () {
67         this.hasCompleted = true;
68         if (this.active === 0 && this.buffer.length === 0) {
69             if (this.hasValue === false) {
70                 this.destination.next(this.acc);
71             }
72             this.destination.complete();
73         }
74         this.unsubscribe();
75     };
76     MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
77         var destination = this.destination;
78         this.acc = innerValue;
79         this.hasValue = true;
80         destination.next(innerValue);
81     };
82     MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
83         var buffer = this.buffer;
84         var destination = this.destination;
85         destination.remove(innerSub);
86         this.active--;
87         if (buffer.length > 0) {
88             this._next(buffer.shift());
89         }
90         else if (this.active === 0 && this.hasCompleted) {
91             if (this.hasValue === false) {
92                 this.destination.next(this.acc);
93             }
94             this.destination.complete();
95         }
96     };
97     return MergeScanSubscriber;
98 }(OuterSubscriber));
99 export { MergeScanSubscriber };
100 //# sourceMappingURL=mergeScan.js.map