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