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