jsmodern
Version:
An extension to existing JavaScript, influenced by other great languages such as Rust, Dart, Java, Golang, etc.
24 lines • 717 B
JavaScript
import { utilIsSet } from './is-set';
export const symmetricDifference = {
label: 'symmetricDifference',
fn: function setSymmetricDifference(other) {
const ctx = this;
if (!utilIsSet(other))
throw new TypeError(`Expect 'other' to be a Set`);
if (!ctx.size && !other.size)
return [];
const symDiffList = [];
for (const n of ctx) {
if (other.has(n))
continue;
symDiffList.push(n);
}
for (const n of other) {
if (ctx.has(n))
continue;
symDiffList.push(n);
}
return symDiffList;
},
};
//# sourceMappingURL=symmetric-difference.js.map