source: trip-planner-front/node_modules/rxjs/internal/operators/exhaustMap.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1"use strict";
2var __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})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var map_1 = require("./map");
17var from_1 = require("../observable/from");
18var innerSubscribe_1 = require("../innerSubscribe");
19function exhaustMap(project, resultSelector) {
20 if (resultSelector) {
21 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); })); })); };
22 }
23 return function (source) {
24 return source.lift(new ExhaustMapOperator(project));
25 };
26}
27exports.exhaustMap = exhaustMap;
28var ExhaustMapOperator = (function () {
29 function ExhaustMapOperator(project) {
30 this.project = project;
31 }
32 ExhaustMapOperator.prototype.call = function (subscriber, source) {
33 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
34 };
35 return ExhaustMapOperator;
36}());
37var ExhaustMapSubscriber = (function (_super) {
38 __extends(ExhaustMapSubscriber, _super);
39 function ExhaustMapSubscriber(destination, project) {
40 var _this = _super.call(this, destination) || this;
41 _this.project = project;
42 _this.hasSubscription = false;
43 _this.hasCompleted = false;
44 _this.index = 0;
45 return _this;
46 }
47 ExhaustMapSubscriber.prototype._next = function (value) {
48 if (!this.hasSubscription) {
49 this.tryNext(value);
50 }
51 };
52 ExhaustMapSubscriber.prototype.tryNext = function (value) {
53 var result;
54 var index = this.index++;
55 try {
56 result = this.project(value, index);
57 }
58 catch (err) {
59 this.destination.error(err);
60 return;
61 }
62 this.hasSubscription = true;
63 this._innerSub(result);
64 };
65 ExhaustMapSubscriber.prototype._innerSub = function (result) {
66 var innerSubscriber = new innerSubscribe_1.SimpleInnerSubscriber(this);
67 var destination = this.destination;
68 destination.add(innerSubscriber);
69 var innerSubscription = innerSubscribe_1.innerSubscribe(result, innerSubscriber);
70 if (innerSubscription !== innerSubscriber) {
71 destination.add(innerSubscription);
72 }
73 };
74 ExhaustMapSubscriber.prototype._complete = function () {
75 this.hasCompleted = true;
76 if (!this.hasSubscription) {
77 this.destination.complete();
78 }
79 this.unsubscribe();
80 };
81 ExhaustMapSubscriber.prototype.notifyNext = function (innerValue) {
82 this.destination.next(innerValue);
83 };
84 ExhaustMapSubscriber.prototype.notifyError = function (err) {
85 this.destination.error(err);
86 };
87 ExhaustMapSubscriber.prototype.notifyComplete = function () {
88 this.hasSubscription = false;
89 if (this.hasCompleted) {
90 this.destination.complete();
91 }
92 };
93 return ExhaustMapSubscriber;
94}(innerSubscribe_1.SimpleOuterSubscriber));
95//# sourceMappingURL=exhaustMap.js.map
Note: See TracBrowser for help on using the repository browser.