Bump to v4.0.0.

This commit is contained in:
John-David Dalton
2015-09-17 17:52:09 -07:00
parent 1d77dfa4b7
commit 54e7baecc3
675 changed files with 11257 additions and 8085 deletions

View File

@@ -1,41 +1,52 @@
import baseIndexOf from './baseIndexOf';
import cacheIndexOf from './cacheIndexOf';
import createCache from './createCache';
import SetCache from './SetCache';
import arrayIncludes from './arrayIncludes';
import arrayIncludesWith from './arrayIncludesWith';
import cacheHas from './cacheHas';
import createSet from './createSet';
import setToArray from './setToArray';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of `_.uniq` without support for callback shorthands
* and `this` binding.
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The function invoked per iteration.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee) {
function baseUniq(array, iteratee, comparator) {
var index = -1,
indexOf = baseIndexOf,
includes = arrayIncludes,
length = array.length,
isCommon = true,
isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
seen = isLarge ? createCache() : null,
result = [];
result = [],
seen = result;
if (seen) {
indexOf = cacheIndexOf;
if (comparator) {
isCommon = false;
} else {
isLarge = false;
includes = arrayIncludesWith;
}
else if (length >= LARGE_ARRAY_SIZE) {
var set = iteratee ? null : createSet(array);
if (set) {
return setToArray(set);
}
isCommon = false;
includes = cacheHas;
seen = new SetCache;
}
else {
seen = iteratee ? [] : result;
}
outer:
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value, index, array) : value;
computed = iteratee ? iteratee(value) : value;
if (isCommon && value === value) {
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) {
if (seen[seenIndex] === computed) {
@@ -47,8 +58,8 @@ function baseUniq(array, iteratee) {
}
result.push(value);
}
else if (indexOf(seen, computed, 0) < 0) {
if (iteratee || isLarge) {
else if (!includes(seen, computed, comparator)) {
if (seen !== result) {
seen.push(computed);
}
result.push(value);