1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 | 1
2
1
1
1
1
1
1
1
161
161
1
1
1
186
186
186
186
1
186
1
1
1
1
1
186
186
186
186
186
186
186
186
186
1
325
286
286
286
286
286
286
39
1
286
1
163
163
12
1
752
752
136
136
8
128
616
1
39
1
171
171
171
171
20
151
61
1
1
| var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var tryCatch_1 = require('../util/tryCatch');
var errorObject_1 = require('../util/errorObject');
var OuterSubscriber_1 = require('../OuterSubscriber');
var subscribeToResult_1 = require('../util/subscribeToResult');
function mergeMapTo(observable, resultSelector, concurrent) {
if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
return this.lift(new MergeMapToOperator(observable, resultSelector, concurrent));
}
exports.mergeMapTo = mergeMapTo;
var MergeMapToOperator = (function () {
function MergeMapToOperator(ish, resultSelector, concurrent) {
Iif (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
this.ish = ish;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
}
MergeMapToOperator.prototype.call = function (observer) {
return new MergeMapToSubscriber(observer, this.ish, this.resultSelector, this.concurrent);
};
return MergeMapToOperator;
})();
exports.MergeMapToOperator = MergeMapToOperator;
var MergeMapToSubscriber = (function (_super) {
__extends(MergeMapToSubscriber, _super);
function MergeMapToSubscriber(destination, ish, resultSelector, concurrent) {
Iif (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
_super.call(this, destination);
this.ish = ish;
this.resultSelector = resultSelector;
this.concurrent = concurrent;
this.hasCompleted = false;
this.buffer = [];
this.active = 0;
this.index = 0;
}
MergeMapToSubscriber.prototype._next = function (value) {
if (this.active < this.concurrent) {
var resultSelector = this.resultSelector;
var index = this.index++;
var ish = this.ish;
var destination = this.destination;
this.active++;
this._innerSub(ish, destination, resultSelector, value, index);
}
else {
this.buffer.push(value);
}
};
MergeMapToSubscriber.prototype._innerSub = function (ish, destination, resultSelector, value, index) {
this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));
};
MergeMapToSubscriber.prototype._complete = function () {
this.hasCompleted = true;
if (this.active === 0 && this.buffer.length === 0) {
this.destination.complete();
}
};
MergeMapToSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
var _a = this, resultSelector = _a.resultSelector, destination = _a.destination;
if (resultSelector) {
var result = tryCatch_1.tryCatch(resultSelector)(outerValue, innerValue, outerIndex, innerIndex);
if (result === errorObject_1.errorObject) {
destination.error(errorObject_1.errorObject.e);
}
else {
destination.next(result);
}
}
else {
destination.next(innerValue);
}
};
MergeMapToSubscriber.prototype.notifyError = function (err) {
this.destination.error(err);
};
MergeMapToSubscriber.prototype.notifyComplete = function (innerSub) {
var buffer = this.buffer;
this.remove(innerSub);
this.active--;
if (buffer.length > 0) {
this._next(buffer.shift());
}
else if (this.active === 0 && this.hasCompleted) {
this.destination.complete();
}
};
return MergeMapToSubscriber;
})(OuterSubscriber_1.OuterSubscriber);
exports.MergeMapToSubscriber = MergeMapToSubscriber;
//# sourceMappingURL=mergeMapTo.js.map |