@nesvet/n
Version:
Various utilities
14 lines • 557 B
JavaScript
export function intersection(...iterables) {
const intersectionArray = [];
if (iterables.length) {
const [firstIterable, ...otherIterables] = iterables;
mainLoop: for (const item of firstIterable) {
for (const otherIterable of otherIterables)
if (otherIterable instanceof Set ? !otherIterable.has(item) : !otherIterable.includes(item))
continue mainLoop;
intersectionArray.push(item);
}
}
return intersectionArray;
}
//# sourceMappingURL=intersection.js.map