Rework _.intersection.

Former-commit-id: b05442888b15b448f6594b46b5cf1a2a06611da2
This commit is contained in:
John-David Dalton
2012-10-20 19:10:56 -07:00
parent a0c91b8754
commit 850d55ab45
4 changed files with 73 additions and 69 deletions

View File

@@ -2702,19 +2702,21 @@
function intersection(array) {
var args = arguments,
argsLength = args.length,
cache = [];
cache = [],
result = [];
return filter(array, function(value) {
forEach(array, function(value) {
if (indexOf(result, value) < 0) {
var length = argsLength;
while (--length) {
if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) {
return false;
return;
}
}
return true;
result.push(value);
}
});
return result;
}
/**