ts-prime
Version:
A utility library for JavaScript and Typescript.
32 lines (31 loc) • 961 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var purry_1 = require("./purry");
var _reduceLazy_1 = require("./_reduceLazy");
function intersection() {
return purry_1.purry(_intersection, arguments, intersection.lazy);
}
exports.intersection = intersection;
function _intersection(array, other) {
var lazy = intersection.lazy(other);
return _reduceLazy_1._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 = exports.intersection || (exports.intersection = {}));