* Creates an array of unique values present in all provided arrays using * strict equality for comparisons, i.e. `===`. * * @static * @memberOf _ * @category Arrays * @param {...Array} [array] The arrays to inspect. * @returns {Array} Returns an array of shared val
()
| 39622 | * // => [1, 2] |
| 39623 | */ |
| 39624 | function intersection() { |
| 39625 | var args = [], |
| 39626 | argsIndex = -1, |
| 39627 | argsLength = arguments.length, |
| 39628 | caches = getArray(), |
| 39629 | indexOf = getIndexOf(), |
| 39630 | trustIndexOf = indexOf === baseIndexOf, |
| 39631 | seen = getArray(); |
| 39632 | |
| 39633 | while (++argsIndex < argsLength) { |
| 39634 | var value = arguments[argsIndex]; |
| 39635 | if (isArray(value) || isArguments(value)) { |
| 39636 | args.push(value); |
| 39637 | caches.push(trustIndexOf && value.length >= largeArraySize && |
| 39638 | createCache(argsIndex ? args[argsIndex] : seen)); |
| 39639 | } |
| 39640 | } |
| 39641 | var array = args[0], |
| 39642 | index = -1, |
| 39643 | length = array ? array.length : 0, |
| 39644 | result = []; |
| 39645 | |
| 39646 | outer: |
| 39647 | while (++index < length) { |
| 39648 | var cache = caches[0]; |
| 39649 | value = array[index]; |
| 39650 | |
| 39651 | if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) { |
| 39652 | argsIndex = argsLength; |
| 39653 | (cache || seen).push(value); |
| 39654 | while (--argsIndex) { |
| 39655 | cache = caches[argsIndex]; |
| 39656 | if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { |
| 39657 | continue outer; |
| 39658 | } |
| 39659 | } |
| 39660 | result.push(value); |
| 39661 | } |
| 39662 | } |
| 39663 | while (argsLength--) { |
| 39664 | cache = caches[argsLength]; |
| 39665 | if (cache) { |
| 39666 | releaseObject(cache); |
| 39667 | } |
| 39668 | } |
| 39669 | releaseArray(caches); |
| 39670 | releaseArray(seen); |
| 39671 | return result; |
| 39672 | } |
| 39673 | |
| 39674 | /** |
| 39675 | * Gets the last element or last `n` elements of an array. If a callback is |
nothing calls this directly
no test coverage detected