15606187c05715a0322996366c23a66107973a6a
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / internal / operators / exhaustMap.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 OuterSubscriber_1 = require("../OuterSubscriber");
17 var InnerSubscriber_1 = require("../InnerSubscriber");
18 var subscribeToResult_1 = require("../util/subscribeToResult");
19 var map_1 = require("./map");
20 var from_1 = require("../observable/from");
21 function exhaustMap(project, resultSelector) {
22     if (resultSelector) {
23         return function (source) { return source.pipe(exhaustMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
24     }
25     return function (source) {
26         return source.lift(new ExhaustMapOperator(project));
27     };
28 }
29 exports.exhaustMap = exhaustMap;
30 var ExhaustMapOperator = (function () {
31     function ExhaustMapOperator(project) {
32         this.project = project;
33     }
34     ExhaustMapOperator.prototype.call = function (subscriber, source) {
35         return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
36     };
37     return ExhaustMapOperator;
38 }());
39 var ExhaustMapSubscriber = (function (_super) {
40     __extends(ExhaustMapSubscriber, _super);
41     function ExhaustMapSubscriber(destination, project) {
42         var _this = _super.call(this, destination) || this;
43         _this.project = project;
44         _this.hasSubscription = false;
45         _this.hasCompleted = false;
46         _this.index = 0;
47         return _this;
48     }
49     ExhaustMapSubscriber.prototype._next = function (value) {
50         if (!this.hasSubscription) {
51             this.tryNext(value);
52         }
53     };
54     ExhaustMapSubscriber.prototype.tryNext = function (value) {
55         var result;
56         var index = this.index++;
57         try {
58             result = this.project(value, index);
59         }
60         catch (err) {
61             this.destination.error(err);
62             return;
63         }
64         this.hasSubscription = true;
65         this._innerSub(result, value, index);
66     };
67     ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
68         var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, value, index);
69         var destination = this.destination;
70         destination.add(innerSubscriber);
71         var innerSubscription = subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
72         if (innerSubscription !== innerSubscriber) {
73             destination.add(innerSubscription);
74         }
75     };
76     ExhaustMapSubscriber.prototype._complete = function () {
77         this.hasCompleted = true;
78         if (!this.hasSubscription) {
79             this.destination.complete();
80         }
81         this.unsubscribe();
82     };
83     ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
84         this.destination.next(innerValue);
85     };
86     ExhaustMapSubscriber.prototype.notifyError = function (err) {
87         this.destination.error(err);
88     };
89     ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
90         var destination = this.destination;
91         destination.remove(innerSub);
92         this.hasSubscription = false;
93         if (this.hasCompleted) {
94             this.destination.complete();
95         }
96     };
97     return ExhaustMapSubscriber;
98 }(OuterSubscriber_1.OuterSubscriber));
99 //# sourceMappingURL=exhaustMap.js.map