UNPKG

jsmodern

Version:

An extension to existing JavaScript, influenced by other great languages such as Rust, Dart, Java, Golang, etc.

17 lines 539 B
import { utilIsSet } from './is-set'; export const intersection = { label: 'intersection', fn: function setIntersection(other) { const ctx = this; if (!utilIsSet(other)) throw new TypeError(`Expect 'other' to be a Set`); if (!ctx.size && !other.size) return []; const intersectionList = []; for (const n of ctx) if (other.has(n)) intersectionList.push(n); return intersectionList; }, }; //# sourceMappingURL=intersection.js.map