1 var baseIndexOf = require('../internal/baseIndexOf'),
2 cacheIndexOf = require('../internal/cacheIndexOf'),
3 createCache = require('../internal/createCache'),
4 isArrayLike = require('../internal/isArrayLike'),
5 restParam = require('../function/restParam');
8 * Creates an array of unique values that are included in all of the provided
9 * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
10 * for equality comparisons.
15 * @param {...Array} [arrays] The arrays to inspect.
16 * @returns {Array} Returns the new array of shared values.
18 * _.intersection([1, 2], [4, 2], [2, 1]);
21 var intersection = restParam(function(arrays) {
22 var othLength = arrays.length,
24 caches = Array(length),
25 indexOf = baseIndexOf,
30 var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
31 caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
33 var array = arrays[0],
35 length = array ? array.length : 0,
39 while (++index < length) {
41 if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
42 var othIndex = othLength;
44 var cache = caches[othIndex];
45 if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
58 module.exports = intersection;