mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Remove "Collections" method _.forEach dependency from "Arrays" method _.intersection.
Former-commit-id: 83197c7ac47654c6fc2d2f37df8ff77d4adb9096
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -2887,20 +2887,24 @@
|
||||
function intersection(array) {
|
||||
var args = arguments,
|
||||
argsLength = args.length,
|
||||
index = -1,
|
||||
length = array ? array.length : 0,
|
||||
cache = {},
|
||||
result = [];
|
||||
|
||||
forEach(array, function(value) {
|
||||
outer:
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (indexOf(result, value) < 0) {
|
||||
var length = argsLength;
|
||||
while (--length) {
|
||||
if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) {
|
||||
return;
|
||||
var argsIndex = argsLength;
|
||||
while (--argsIndex) {
|
||||
if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex])))(value)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
result.push(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user