Remove "Collections" method _.forEach dependency from "Arrays" method _.intersection.

Former-commit-id: 83197c7ac47654c6fc2d2f37df8ff77d4adb9096
This commit is contained in:
John-David Dalton
2012-12-11 09:35:51 -08:00
parent 1a3c20f91d
commit 24fce89155
6 changed files with 91 additions and 79 deletions

View File

@@ -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;
}