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 var nativeMin = Math.min;
21 function baseIntersection(arrays, iteratee, comparator) {
22 var includes = comparator ? arrayIncludesWith : arrayIncludes,
23 length = arrays[0].length,
24 othLength = arrays.length,
26 caches = Array(othLength),
31 var array = arrays[othIndex];
32 if (othIndex && iteratee) {
33 array = arrayMap(array, baseUnary(iteratee));
35 maxLength = nativeMin(array.length, maxLength);
36 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
37 ?
new SetCache(othIndex && array)
46 while (++index < length && result.length < maxLength) {
47 var value = array[index],
48 computed = iteratee ? iteratee(value) : value;
50 value = (comparator || value !== 0) ? value : 0;
52 ? cacheHas(seen, computed)
53 : includes(result, computed, comparator)
57 var cache = caches[othIndex];
59 ? cacheHas(cache, computed)
60 : includes(arrays[othIndex], computed, comparator))
74 module.exports = baseIntersection;