setup-maven-cached/node_modules/underscore/cjs/intersection.js

22 lines
599 B
JavaScript
Raw Permalink Normal View History

2022-06-28 16:39:30 +08:00
var _getLength = require('./_getLength.js');
var contains = require('./contains.js');
// Produce an array that contains every item shared between all the
// passed-in arrays.
function intersection(array) {
var result = [];
var argsLength = arguments.length;
for (var i = 0, length = _getLength(array); i < length; i++) {
var item = array[i];
if (contains(result, item)) continue;
var j;
for (j = 1; j < argsLength; j++) {
if (!contains(arguments[j], item)) break;
}
if (j === argsLength) result.push(item);
}
return result;
}
module.exports = intersection;