linq-extensions
Version:
Linq-like extension methods for JavaScript and TypeScript builtin collections
34 lines • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OuterJoinIterable = void 0;
const iterable_1 = require("../../iterable");
class OuterJoinIterable extends iterable_1.Iterable {
constructor(left, right, on, into) {
super();
this.left = left;
this.right = right;
this.on = on;
this.into = into;
}
*[Symbol.iterator]() {
const unusedRightElements = this.right.toSet();
for (const left of this.left) {
let didJoin = false;
for (const right of this.right) {
if (this.on(left, right)) {
didJoin = true;
unusedRightElements.delete(right);
yield this.into(left, right);
}
}
if (!didJoin) {
yield this.into(left, null);
}
}
for (const element of unusedRightElements) {
yield this.into(null, element);
}
}
}
exports.OuterJoinIterable = OuterJoinIterable;
//# sourceMappingURL=outer-join-iterable.js.map