1 var SetCache = require('./_SetCache'),
2 arrayIncludes = require('./_arrayIncludes'),
3 arrayIncludesWith = require('./_arrayIncludesWith'),
4 arrayMap = require('./_arrayMap'),
5 baseUnary = require('./_baseUnary'),
6 cacheHas = require('./_cacheHas');
9 * The base implementation of methods like `_.intersection`, without support
10 * for iteratee shorthands, that accepts an array of arrays to inspect.
13 * @param {Array} arrays The arrays to inspect.
14 * @param {Function} [iteratee] The iteratee invoked per element.
15 * @param {Function} [comparator] The comparator invoked per element.
16 * @returns {Array} Returns the new array of shared values.
18 function baseIntersection(arrays, iteratee, comparator) {
19 var includes = comparator ? arrayIncludesWith : arrayIncludes,
20 othLength = arrays.length,
22 caches = Array(othLength),
26 var array = arrays[othIndex];
27 if (othIndex && iteratee) {
28 array = arrayMap(array, baseUnary(iteratee));
30 caches[othIndex] = !comparator && (iteratee || array.length >= 120)
31 ? new SetCache(othIndex && array)
37 length = array.length,
41 while (++index < length) {
42 var value = array[index],
43 computed = iteratee ? iteratee(value) : value;
45 if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
46 var othIndex = othLength;
48 var cache = caches[othIndex];
49 if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
62 module.exports = baseIntersection;