UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

84 lines (82 loc) 3.92 kB
import { __extends, __generator, __values } from "tslib"; import { IterableX } from '../iterablex.js'; import { createGrouping } from './_grouping.js'; import { empty } from '../empty.js'; import { identity } from '../../util/identity.js'; /** @ignore */ var GroupJoinIterable = /** @class */ (function (_super) { __extends(GroupJoinIterable, _super); function GroupJoinIterable(outer, inner, outerSelector, innerSelector, resultSelector) { var _this = _super.call(this) || this; _this._outer = outer; _this._inner = inner; _this._outerSelector = outerSelector; _this._innerSelector = innerSelector; _this._resultSelector = resultSelector; return _this; } GroupJoinIterable.prototype[Symbol.iterator] = function () { var map, _a, _b, outerElement, outerKey, innerElements, e_1_1; var e_1, _c; return __generator(this, function (_d) { switch (_d.label) { case 0: map = createGrouping(this._inner, this._innerSelector, identity); _d.label = 1; case 1: _d.trys.push([1, 6, 7, 8]); _a = __values(this._outer), _b = _a.next(); _d.label = 2; case 2: if (!!_b.done) return [3 /*break*/, 5]; outerElement = _b.value; outerKey = this._outerSelector(outerElement); innerElements = map.has(outerKey) ? map.get(outerKey) : empty(); return [4 /*yield*/, this._resultSelector(outerElement, innerElements)]; case 3: _d.sent(); _d.label = 4; case 4: _b = _a.next(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 8]; case 6: e_1_1 = _d.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 8]; case 7: try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_1) throw e_1.error; } return [7 /*endfinally*/]; case 8: return [2 /*return*/]; } }); }; return GroupJoinIterable; }(IterableX)); export { GroupJoinIterable }; /** * Correlates the elements of two iterable sequences based on equality of keys and groups the results. * * @template TOuter The type of the elements of the first iterable sequence. * @template TInner The type of the elements of the second iterable sequence. * @template TKey The type of the keys returned by the key selector functions. * @template TResult The type of the result elements. * @param {Iterable<TInner>} inner The async-enumerable sequence to join to the first sequence. * @param {((value: TOuter) => TKey)} outerSelector A function to extract the join key from each * element of the first sequence. * @param {((value: TInner) => TKey)} innerSelector A function to extract the join key from each * element of the second sequence. * @param {((outer: TOuter, inner: Iterable<TInner>) => TResult)} resultSelector A function to create a result * element from an element from the first sequence and a collection of matching elements from the second sequence. * @returns {OperatorFunction<TOuter, TResult>} An operator that returns an iterable sequence that contains the result elements * that are obtained by performing a grouped join on two sequences. */ export function groupJoin(inner, outerSelector, innerSelector, resultSelector) { return function groupJoinOperatorFunction(outer) { return new GroupJoinIterable(outer, inner, outerSelector, innerSelector, resultSelector); }; } //# sourceMappingURL=groupjoin.js.map