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