883d2f922f05e7b13a118307de5f6beacbbeabbd
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / _esm5 / internal / operators / exhaustMap.js
1 /** PURE_IMPORTS_START tslib,_OuterSubscriber,_InnerSubscriber,_util_subscribeToResult,_map,_observable_from PURE_IMPORTS_END */
2 import * as tslib_1 from "tslib";
3 import { OuterSubscriber } from '../OuterSubscriber';
4 import { InnerSubscriber } from '../InnerSubscriber';
5 import { subscribeToResult } from '../util/subscribeToResult';
6 import { map } from './map';
7 import { from } from '../observable/from';
8 export function exhaustMap(project, resultSelector) {
9     if (resultSelector) {
10         return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
11     }
12     return function (source) {
13         return source.lift(new ExhaustMapOperator(project));
14     };
15 }
16 var ExhaustMapOperator = /*@__PURE__*/ (function () {
17     function ExhaustMapOperator(project) {
18         this.project = project;
19     }
20     ExhaustMapOperator.prototype.call = function (subscriber, source) {
21         return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
22     };
23     return ExhaustMapOperator;
24 }());
25 var ExhaustMapSubscriber = /*@__PURE__*/ (function (_super) {
26     tslib_1.__extends(ExhaustMapSubscriber, _super);
27     function ExhaustMapSubscriber(destination, project) {
28         var _this = _super.call(this, destination) || this;
29         _this.project = project;
30         _this.hasSubscription = false;
31         _this.hasCompleted = false;
32         _this.index = 0;
33         return _this;
34     }
35     ExhaustMapSubscriber.prototype._next = function (value) {
36         if (!this.hasSubscription) {
37             this.tryNext(value);
38         }
39     };
40     ExhaustMapSubscriber.prototype.tryNext = function (value) {
41         var result;
42         var index = this.index++;
43         try {
44             result = this.project(value, index);
45         }
46         catch (err) {
47             this.destination.error(err);
48             return;
49         }
50         this.hasSubscription = true;
51         this._innerSub(result, value, index);
52     };
53     ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
54         var innerSubscriber = new InnerSubscriber(this, value, index);
55         var destination = this.destination;
56         destination.add(innerSubscriber);
57         var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
58         if (innerSubscription !== innerSubscriber) {
59             destination.add(innerSubscription);
60         }
61     };
62     ExhaustMapSubscriber.prototype._complete = function () {
63         this.hasCompleted = true;
64         if (!this.hasSubscription) {
65             this.destination.complete();
66         }
67         this.unsubscribe();
68     };
69     ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
70         this.destination.next(innerValue);
71     };
72     ExhaustMapSubscriber.prototype.notifyError = function (err) {
73         this.destination.error(err);
74     };
75     ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
76         var destination = this.destination;
77         destination.remove(innerSub);
78         this.hasSubscription = false;
79         if (this.hasCompleted) {
80             this.destination.complete();
81         }
82     };
83     return ExhaustMapSubscriber;
84 }(OuterSubscriber));
85 //# sourceMappingURL=exhaustMap.js.map