pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
20 lines (19 loc) • 562 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.differenceWith = void 0;
const main_1 = require("./main");
function differenceWith(setA, setB) {
if (arguments.length === 1) {
return (b) => differenceWith(setA, b);
}
const a = (0, main_1.getValueOr)([], setA);
const b = new Set((0, main_1.getValueOr)([], setB));
const result = [];
a.forEach((elem) => {
if (!b.has(elem)) {
result.push(elem);
}
});
return result;
}
exports.differenceWith = differenceWith;