ts-prime
Version:
A utility library for JavaScript and Typescript.
29 lines (28 loc) • 799 B
JavaScript
import { purry } from './purry';
import { _reduceLazy } from './_reduceLazy';
export function intersection() {
return purry(_intersection, arguments, intersection.lazy);
}
function _intersection(array, other) {
var lazy = intersection.lazy(other);
return _reduceLazy(array, lazy);
}
(function (intersection) {
function lazy(other) {
return function (value) {
var set = new Set(other);
if (set.has(value)) {
return {
done: false,
hasNext: true,
next: value,
};
}
return {
done: false,
hasNext: false,
};
};
}
intersection.lazy = lazy;
})(intersection || (intersection = {}));