@reactivex/ix-es2015-cjs
Version:
The Interactive Extensions for JavaScript
79 lines (77 loc) • 3.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.concatMap = void 0;
const tslib_1 = require("tslib");
const asynciterablex_js_1 = require("../asynciterablex.js");
const withabort_js_1 = require("./withabort.js");
const aborterror_js_1 = require("../../aborterror.js");
const isiterable_js_1 = require("../../util/isiterable.js");
class ConcatMapAsyncIterable extends asynciterablex_js_1.AsyncIterableX {
constructor(_source, _selector, _thisArg) {
super();
this._source = _source;
this._selector = _selector;
this._thisArg = _thisArg;
}
[Symbol.asyncIterator](signal) {
return tslib_1.__asyncGenerator(this, arguments, function* _a() {
var _b, e_1, _c, _d, _e, e_2, _f, _g;
(0, aborterror_js_1.throwIfAborted)(signal);
let outerIndex = 0;
const { _thisArg: thisArg, _selector: selector } = this;
try {
for (var _h = true, _j = tslib_1.__asyncValues((0, withabort_js_1.wrapWithAbort)(this._source, signal)), _k; _k = yield tslib_1.__await(_j.next()), _b = _k.done, !_b; _h = true) {
_d = _k.value;
_h = false;
const outer = _d;
const result = selector.call(thisArg, outer, outerIndex++, signal);
const values = ((0, isiterable_js_1.isPromise)(result) ? yield tslib_1.__await(result) : result);
try {
for (var _l = true, _m = (e_2 = void 0, tslib_1.__asyncValues((0, withabort_js_1.wrapWithAbort)(asynciterablex_js_1.AsyncIterableX.as(values), signal))), _o; _o = yield tslib_1.__await(_m.next()), _e = _o.done, !_e; _l = true) {
_g = _o.value;
_l = false;
const inner = _g;
yield yield tslib_1.__await(inner);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (!_l && !_e && (_f = _m.return)) yield tslib_1.__await(_f.call(_m));
}
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_h && !_b && (_c = _j.return)) yield tslib_1.__await(_c.call(_j));
}
finally { if (e_1) throw e_1.error; }
}
});
}
}
/**
* Projects each element of an async-iterable sequence to an async-iterable sequence and merges
* the resulting async-iterable sequences into one async-iterable sequence.
*
* @template TSource The type of the elements in the source sequence.
* @template TResult The type of the elements in the projected inner sequences and the elements in the merged result sequence.
* @param {((
* value: TSource,
* index: number,
* signal?: AbortSignal
* ) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>)} selector A transform function to apply to each element.
* @param {*} [thisArg] Option this for binding to the selector.
* @returns {OperatorAsyncFunction<TSource, TResult>} An operator that creates an async-iterable sequence whose
* elements are the result of invoking the one-to-many transform function on each element of the input sequence.
*/
function concatMap(selector, thisArg) {
return function concatMapOperatorFunction(source) {
return new ConcatMapAsyncIterable(source, selector, thisArg);
};
}
exports.concatMap = concatMap;
//# sourceMappingURL=concatmap.js.map