Bump to v3.9.0.

This commit is contained in:
jdalton
2015-05-17 22:50:59 -07:00
parent d7b2bedafc
commit 30daf83737
89 changed files with 527 additions and 567 deletions

View File

@@ -2,6 +2,7 @@ import baseIndexOf from '../internal/baseIndexOf';
import cacheIndexOf from '../internal/cacheIndexOf';
import createCache from '../internal/createCache';
import isArrayLike from '../internal/isArrayLike';
import restParam from '../function/restParam';
/**
* Creates an array of unique values in all provided arrays using
@@ -17,27 +18,19 @@ import isArrayLike from '../internal/isArrayLike';
* _.intersection([1, 2], [4, 2], [2, 1]);
* // => [2]
*/
function intersection() {
var args = [],
argsIndex = -1,
argsLength = arguments.length,
caches = [],
var intersection = restParam(function(arrays) {
var othLength = arrays.length,
othIndex = othLength,
caches = Array(length),
indexOf = baseIndexOf,
isCommon = true,
result = [];
while (++argsIndex < argsLength) {
var value = arguments[argsIndex];
if (isArrayLike(value)) {
args.push(value);
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
}
while (othIndex--) {
var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
}
argsLength = args.length;
if (argsLength < 2) {
return result;
}
var array = args[0],
var array = arrays[0],
index = -1,
length = array ? array.length : 0,
seen = caches[0];
@@ -46,10 +39,10 @@ function intersection() {
while (++index < length) {
value = array[index];
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
argsIndex = argsLength;
while (--argsIndex) {
var cache = caches[argsIndex];
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) {
var othIndex = othLength;
while (--othIndex) {
var cache = caches[othIndex];
if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
continue outer;
}
}
@@ -60,6 +53,6 @@ function intersection() {
}
}
return result;
}
});
export default intersection;