Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / internal / operators / mergeScan.js
1 "use strict";
2 var __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 })();
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var innerSubscribe_1 = require("../innerSubscribe");
17 function mergeScan(accumulator, seed, concurrent) {
18     if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
19     return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
20 }
21 exports.mergeScan = mergeScan;
22 var MergeScanOperator = (function () {
23     function MergeScanOperator(accumulator, seed, concurrent) {
24         this.accumulator = accumulator;
25         this.seed = seed;
26         this.concurrent = concurrent;
27     }
28     MergeScanOperator.prototype.call = function (subscriber, source) {
29         return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
30     };
31     return MergeScanOperator;
32 }());
33 exports.MergeScanOperator = MergeScanOperator;
34 var MergeScanSubscriber = (function (_super) {
35     __extends(MergeScanSubscriber, _super);
36     function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
37         var _this = _super.call(this, destination) || this;
38         _this.accumulator = accumulator;
39         _this.acc = acc;
40         _this.concurrent = concurrent;
41         _this.hasValue = false;
42         _this.hasCompleted = false;
43         _this.buffer = [];
44         _this.active = 0;
45         _this.index = 0;
46         return _this;
47     }
48     MergeScanSubscriber.prototype._next = function (value) {
49         if (this.active < this.concurrent) {
50             var index = this.index++;
51             var destination = this.destination;
52             var ish = void 0;
53             try {
54                 var accumulator = this.accumulator;
55                 ish = accumulator(this.acc, value, index);
56             }
57             catch (e) {
58                 return destination.error(e);
59             }
60             this.active++;
61             this._innerSub(ish);
62         }
63         else {
64             this.buffer.push(value);
65         }
66     };
67     MergeScanSubscriber.prototype._innerSub = function (ish) {
68         var innerSubscriber = new innerSubscribe_1.SimpleInnerSubscriber(this);
69         var destination = this.destination;
70         destination.add(innerSubscriber);
71         var innerSubscription = innerSubscribe_1.innerSubscribe(ish, innerSubscriber);
72         if (innerSubscription !== innerSubscriber) {
73             destination.add(innerSubscription);
74         }
75     };
76     MergeScanSubscriber.prototype._complete = function () {
77         this.hasCompleted = true;
78         if (this.active === 0 && this.buffer.length === 0) {
79             if (this.hasValue === false) {
80                 this.destination.next(this.acc);
81             }
82             this.destination.complete();
83         }
84         this.unsubscribe();
85     };
86     MergeScanSubscriber.prototype.notifyNext = function (innerValue) {
87         var destination = this.destination;
88         this.acc = innerValue;
89         this.hasValue = true;
90         destination.next(innerValue);
91     };
92     MergeScanSubscriber.prototype.notifyComplete = function () {
93         var buffer = this.buffer;
94         this.active--;
95         if (buffer.length > 0) {
96             this._next(buffer.shift());
97         }
98         else if (this.active === 0 && this.hasCompleted) {
99             if (this.hasValue === false) {
100                 this.destination.next(this.acc);
101             }
102             this.destination.complete();
103         }
104     };
105     return MergeScanSubscriber;
106 }(innerSubscribe_1.SimpleOuterSubscriber));
107 exports.MergeScanSubscriber = MergeScanSubscriber;
108 //# sourceMappingURL=mergeScan.js.map