Compare commits

...

3 Commits

Author SHA1 Message Date
John-David Dalton
07c844053e Bump to v4.12.0. 2016-05-08 12:23:20 -07:00
John-David Dalton
35805ec250 Bump to v4.11.2. 2016-04-21 07:06:47 -07:00
John-David Dalton
692aabae13 Bump to v4.11.1. 2016-04-13 21:03:52 -07:00
192 changed files with 936 additions and 646 deletions

View File

@@ -1,4 +1,4 @@
# lodash-es v4.11.0 # lodash-es v4.12.0
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules. The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
$ lodash modularize exports=es -o ./ $ lodash modularize exports=es -o ./
``` ```
See the [package source](https://github.com/lodash/lodash/tree/4.11.0-es) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.12.0-es) for more details.

View File

@@ -1,18 +1,32 @@
import nativeCreate from './_nativeCreate'; import hashClear from './_hashClear';
import hashDelete from './_hashDelete';
/** Used for built-in method references. */ import hashGet from './_hashGet';
var objectProto = Object.prototype; import hashHas from './_hashHas';
import hashSet from './_hashSet';
/** /**
* Creates a hash object. * Creates a hash object.
* *
* @private * @private
* @constructor * @constructor
* @returns {Object} Returns the new hash object. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function Hash() {} function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
// Avoid inheriting from `Object.prototype` when possible. this.clear();
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
export default Hash; export default Hash;

32
_ListCache.js Normal file
View File

@@ -0,0 +1,32 @@
import listCacheClear from './_listCacheClear';
import listCacheDelete from './_listCacheDelete';
import listCacheGet from './_listCacheGet';
import listCacheHas from './_listCacheHas';
import listCacheSet from './_listCacheSet';
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
export default ListCache;

View File

@@ -1,32 +1,32 @@
import mapClear from './_mapClear'; import mapCacheClear from './_mapCacheClear';
import mapDelete from './_mapDelete'; import mapCacheDelete from './_mapCacheDelete';
import mapGet from './_mapGet'; import mapCacheGet from './_mapCacheGet';
import mapHas from './_mapHas'; import mapCacheHas from './_mapCacheHas';
import mapSet from './_mapSet'; import mapCacheSet from './_mapCacheSet';
/** /**
* Creates a map cache object to store key-value pairs. * Creates a map cache object to store key-value pairs.
* *
* @private * @private
* @constructor * @constructor
* @param {Array} [values] The values to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function MapCache(values) { function MapCache(entries) {
var index = -1, var index = -1,
length = values ? values.length : 0; length = entries ? entries.length : 0;
this.clear(); this.clear();
while (++index < length) { while (++index < length) {
var entry = values[index]; var entry = entries[index];
this.set(entry[0], entry[1]); this.set(entry[0], entry[1]);
} }
} }
// Add methods to `MapCache`. // Add methods to `MapCache`.
MapCache.prototype.clear = mapClear; MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapDelete; MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapGet; MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapHas; MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapSet; MapCache.prototype.set = mapCacheSet;
export default MapCache; export default MapCache;

View File

@@ -1,9 +1,10 @@
import MapCache from './_MapCache'; import MapCache from './_MapCache';
import cachePush from './_cachePush'; import setCacheAdd from './_setCacheAdd';
import setCacheHas from './_setCacheHas';
/** /**
* *
* Creates a set cache object to store unique values. * Creates an array cache object to store unique values.
* *
* @private * @private
* @constructor * @constructor
@@ -15,11 +16,12 @@ function SetCache(values) {
this.__data__ = new MapCache; this.__data__ = new MapCache;
while (++index < length) { while (++index < length) {
this.push(values[index]); this.add(values[index]);
} }
} }
// Add methods to `SetCache`. // Add methods to `SetCache`.
SetCache.prototype.push = cachePush; SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
export default SetCache; export default SetCache;

View File

@@ -1,3 +1,4 @@
import ListCache from './_ListCache';
import stackClear from './_stackClear'; import stackClear from './_stackClear';
import stackDelete from './_stackDelete'; import stackDelete from './_stackDelete';
import stackGet from './_stackGet'; import stackGet from './_stackGet';
@@ -9,17 +10,10 @@ import stackSet from './_stackSet';
* *
* @private * @private
* @constructor * @constructor
* @param {Array} [values] The values to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function Stack(values) { function Stack(entries) {
var index = -1, this.__data__ = new ListCache(entries);
length = values ? values.length : 0;
this.clear();
while (++index < length) {
var entry = values[index];
this.set(entry[0], entry[1]);
}
} }
// Add methods to `Stack`. // Add methods to `Stack`.

View File

@@ -1,25 +0,0 @@
/**
* Creates a new array concatenating `array` with `other`.
*
* @private
* @param {Array} array The first array to concatenate.
* @param {Array} other The second array to concatenate.
* @returns {Array} Returns the new concatenated array.
*/
function arrayConcat(array, other) {
var index = -1,
length = array.length,
othIndex = -1,
othLength = other.length,
result = Array(length + othLength);
while (++index < length) {
result[index] = array[index];
}
while (++othIndex < othLength) {
result[index++] = other[othIndex];
}
return result;
}
export default arrayConcat;

View File

@@ -1,16 +0,0 @@
import assocIndexOf from './_assocIndexOf';
/**
* Gets the associative array value for `key`.
*
* @private
* @param {Array} array The array to query.
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function assocGet(array, key) {
var index = assocIndexOf(array, key);
return index < 0 ? undefined : array[index][1];
}
export default assocGet;

View File

@@ -1,20 +0,0 @@
import assocIndexOf from './_assocIndexOf';
/**
* Sets the associative array `key` to `value`.
*
* @private
* @param {Array} array The array to modify.
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
*/
function assocSet(array, key, value) {
var index = assocIndexOf(array, key);
if (index < 0) {
array.push([key, value]);
} else {
array[index][1] = value;
}
}
export default assocSet;

View File

@@ -6,7 +6,7 @@ import get from './get';
* @private * @private
* @param {Object} object The object to iterate over. * @param {Object} object The object to iterate over.
* @param {string[]} paths The property paths of elements to pick. * @param {string[]} paths The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the picked elements.
*/ */
function baseAt(object, paths) { function baseAt(object, paths) {
var index = -1, var index = -1,

View File

@@ -5,7 +5,7 @@ import keys from './keys';
* *
* @private * @private
* @param {Object} source The object of property predicates to conform to. * @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseConforms(source) { function baseConforms(source) {
var props = keys(source), var props = keys(source),

View File

@@ -47,6 +47,7 @@ function baseDifference(array, values, iteratee, comparator) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
var valuesIndex = valuesLength; var valuesIndex = valuesLength;
while (valuesIndex--) { while (valuesIndex--) {

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/** /**
* The base implementation of methods like `_.max` and `_.min` which accepts a * The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value. * `comparator` to determine the extremum value.
@@ -17,7 +19,7 @@ function baseExtremum(array, iteratee, comparator) {
current = iteratee(value); current = iteratee(value);
if (current != null && (computed === undefined if (current != null && (computed === undefined
? current === current ? (current === current && !isSymbol(current))
: comparator(current, computed) : comparator(current, computed)
)) { )) {
var computed = current, var computed = current,

View File

@@ -8,7 +8,7 @@ import isFunction from './isFunction';
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.
* @param {Array} props The property names to filter. * @param {Array} props The property names to filter.
* @returns {Array} Returns the new array of filtered property names. * @returns {Array} Returns the function names.
*/ */
function baseFunctions(object, props) { function baseFunctions(object, props) {
return arrayFilter(props, function(key) { return arrayFilter(props, function(key) {

View File

@@ -1,5 +1,6 @@
import castPath from './_castPath'; import castPath from './_castPath';
import isKey from './_isKey'; import isKey from './_isKey';
import toKey from './_toKey';
/** /**
* The base implementation of `_.get` without support for default values. * The base implementation of `_.get` without support for default values.
@@ -16,7 +17,7 @@ function baseGet(object, path) {
length = path.length; length = path.length;
while (object != null && index < length) { while (object != null && index < length) {
object = object[path[index++]]; object = object[toKey(path[index++])];
} }
return (index && index == length) ? object : undefined; return (index && index == length) ? object : undefined;
} }

View File

@@ -14,9 +14,7 @@ import isArray from './isArray';
*/ */
function baseGetAllKeys(object, keysFunc, symbolsFunc) { function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object); var result = keysFunc(object);
return isArray(object) return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
? result
: arrayPush(result, symbolsFunc(object));
} }
export default baseGetAllKeys; export default baseGetAllKeys;

14
_baseGt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.gt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
export default baseGt;

View File

@@ -47,6 +47,7 @@ function baseIntersection(arrays, iteratee, comparator) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (!(seen if (!(seen
? cacheHas(seen, computed) ? cacheHas(seen, computed)
: includes(result, computed, comparator) : includes(result, computed, comparator)

View File

@@ -3,6 +3,7 @@ import castPath from './_castPath';
import isKey from './_isKey'; import isKey from './_isKey';
import last from './last'; import last from './last';
import parent from './_parent'; import parent from './_parent';
import toKey from './_toKey';
/** /**
* The base implementation of `_.invoke` without support for individual * The base implementation of `_.invoke` without support for individual
@@ -20,7 +21,7 @@ function baseInvoke(object, path, args) {
object = parent(object, path); object = parent(object, path);
path = last(path); path = last(path);
} }
var func = object == null ? object : object[path]; var func = object == null ? object : object[toKey(path)];
return func == null ? undefined : apply(func, object, args); return func == null ? undefined : apply(func, object, args);
} }

14
_baseLt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.lt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
export default baseLt;

View File

@@ -7,7 +7,7 @@ import matchesStrictComparable from './_matchesStrictComparable';
* *
* @private * @private
* @param {Object} source The object of property values to match. * @param {Object} source The object of property values to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseMatches(source) { function baseMatches(source) {
var matchData = getMatchData(source); var matchData = getMatchData(source);

View File

@@ -4,6 +4,7 @@ import hasIn from './hasIn';
import isKey from './_isKey'; import isKey from './_isKey';
import isStrictComparable from './_isStrictComparable'; import isStrictComparable from './_isStrictComparable';
import matchesStrictComparable from './_matchesStrictComparable'; import matchesStrictComparable from './_matchesStrictComparable';
import toKey from './_toKey';
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1, var UNORDERED_COMPARE_FLAG = 1,
@@ -15,11 +16,11 @@ var UNORDERED_COMPARE_FLAG = 1,
* @private * @private
* @param {string} path The path of the property to get. * @param {string} path The path of the property to get.
* @param {*} srcValue The value to match. * @param {*} srcValue The value to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseMatchesProperty(path, srcValue) { function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) { if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(path, srcValue); return matchesStrictComparable(toKey(path), srcValue);
} }
return function(object) { return function(object) {
var objValue = get(object, path); var objValue = get(object, path);

View File

@@ -3,7 +3,7 @@
* *
* @private * @private
* @param {string} key The key of the property to get. * @param {string} key The key of the property to get.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new accessor function.
*/ */
function baseProperty(key) { function baseProperty(key) {
return function(object) { return function(object) {

View File

@@ -5,7 +5,7 @@ import baseGet from './_baseGet';
* *
* @private * @private
* @param {Array|string} path The path of the property to get. * @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new accessor function.
*/ */
function basePropertyDeep(path) { function basePropertyDeep(path) {
return function(object) { return function(object) {

View File

@@ -3,6 +3,7 @@ import isIndex from './_isIndex';
import isKey from './_isKey'; import isKey from './_isKey';
import last from './last'; import last from './last';
import parent from './_parent'; import parent from './_parent';
import toKey from './_toKey';
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
@@ -25,7 +26,7 @@ function basePullAt(array, indexes) {
while (length--) { while (length--) {
var index = indexes[length]; var index = indexes[length];
if (lastIndex == length || index != previous) { if (length == lastIndex || index !== previous) {
var previous = index; var previous = index;
if (isIndex(index)) { if (isIndex(index)) {
splice.call(array, index, 1); splice.call(array, index, 1);
@@ -35,11 +36,11 @@ function basePullAt(array, indexes) {
object = parent(array, path); object = parent(array, path);
if (object != null) { if (object != null) {
delete object[last(path)]; delete object[toKey(last(path))];
} }
} }
else { else {
delete array[index]; delete array[toKey(index)];
} }
} }
} }

View File

@@ -11,7 +11,7 @@ var nativeCeil = Math.ceil,
* @param {number} end The end of the range. * @param {number} end The end of the range.
* @param {number} step The value to increment or decrement by. * @param {number} step The value to increment or decrement by.
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the new array of numbers. * @returns {Array} Returns the range of numbers.
*/ */
function baseRange(start, end, step, fromRight) { function baseRange(start, end, step, fromRight) {
var index = -1, var index = -1,

View File

@@ -3,6 +3,7 @@ import castPath from './_castPath';
import isIndex from './_isIndex'; import isIndex from './_isIndex';
import isKey from './_isKey'; import isKey from './_isKey';
import isObject from './isObject'; import isObject from './isObject';
import toKey from './_toKey';
/** /**
* The base implementation of `_.set`. * The base implementation of `_.set`.
@@ -23,7 +24,7 @@ function baseSet(object, path, value, customizer) {
nested = object; nested = object;
while (nested != null && ++index < length) { while (nested != null && ++index < length) {
var key = path[index]; var key = toKey(path[index]);
if (isObject(nested)) { if (isObject(nested)) {
var newValue = value; var newValue = value;
if (index != lastIndex) { if (index != lastIndex) {

View File

@@ -1,5 +1,6 @@
import baseSortedIndexBy from './_baseSortedIndexBy'; import baseSortedIndexBy from './_baseSortedIndexBy';
import identity from './identity'; import identity from './identity';
import isSymbol from './isSymbol';
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295, var MAX_ARRAY_LENGTH = 4294967295,
@@ -26,7 +27,8 @@ function baseSortedIndex(array, value, retHighest) {
var mid = (low + high) >>> 1, var mid = (low + high) >>> 1,
computed = array[mid]; computed = array[mid];
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1; low = mid + 1;
} else { } else {
high = mid; high = mid;

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295, var MAX_ARRAY_LENGTH = 4294967295,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
@@ -26,21 +28,26 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
high = array ? array.length : 0, high = array ? array.length : 0,
valIsNaN = value !== value, valIsNaN = value !== value,
valIsNull = value === null, valIsNull = value === null,
valIsUndef = value === undefined; valIsSymbol = isSymbol(value),
valIsUndefined = value === undefined;
while (low < high) { while (low < high) {
var mid = nativeFloor((low + high) / 2), var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]), computed = iteratee(array[mid]),
isDef = computed !== undefined, othIsDefined = computed !== undefined,
isReflexive = computed === computed; othIsNull = computed === null,
othIsReflexive = computed === computed,
othIsSymbol = isSymbol(computed);
if (valIsNaN) { if (valIsNaN) {
var setLow = isReflexive || retHighest; var setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) { } else if (valIsNull) {
setLow = isReflexive && isDef && (retHighest || computed != null); setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
} else if (valIsUndef) { } else if (valIsSymbol) {
setLow = isReflexive && (retHighest || isDef); setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
} else if (computed == null) { } else if (othIsNull || othIsSymbol) {
setLow = false; setLow = false;
} else { } else {
setLow = retHighest ? (computed <= value) : (computed < value); setLow = retHighest ? (computed <= value) : (computed < value);

View File

@@ -1,14 +1,30 @@
import baseSortedUniqBy from './_baseSortedUniqBy'; import eq from './eq';
/** /**
* The base implementation of `_.sortedUniq`. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
* support for iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to inspect. * @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array. * @returns {Array} Returns the new duplicate free array.
*/ */
function baseSortedUniq(array) { function baseSortedUniq(array, iteratee) {
return baseSortedUniqBy(array); var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resIndex++] = value === 0 ? 0 : value;
}
}
return result;
} }
export default baseSortedUniq; export default baseSortedUniq;

View File

@@ -1,33 +0,0 @@
import eq from './eq';
/**
* The base implementation of `_.sortedUniqBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseSortedUniqBy(array, iteratee) {
var index = 0,
length = array.length,
value = array[0],
computed = iteratee ? iteratee(value) : value,
seen = computed,
resIndex = 1,
result = [value];
while (++index < length) {
value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!eq(computed, seen)) {
seen = computed;
result[resIndex++] = value;
}
}
return result;
}
export default baseSortedUniqBy;

24
_baseToNumber.js Normal file
View File

@@ -0,0 +1,24 @@
import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/**
* The base implementation of `_.toNumber` which doesn't ensure correct
* conversions of binary, hexadecimal, or octal string values.
*
* @private
* @param {*} value The value to process.
* @returns {number} Returns the number.
*/
function baseToNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
return +value;
}
export default baseToNumber;

View File

@@ -7,7 +7,7 @@ import arrayMap from './_arrayMap';
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @param {Array} props The property names to get values for. * @param {Array} props The property names to get values for.
* @returns {Object} Returns the new array of key-value pairs. * @returns {Object} Returns the key-value pairs.
*/ */
function baseToPairs(object, props) { function baseToPairs(object, props) {
return arrayMap(props, function(key) { return arrayMap(props, function(key) {

31
_baseToString.js Normal file
View File

@@ -0,0 +1,31 @@
import Symbol from './_Symbol';
import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
export default baseToString;

View File

@@ -3,7 +3,7 @@
* *
* @private * @private
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new capped function.
*/ */
function baseUnary(func) { function baseUnary(func) {
return function(value) { return function(value) {

View File

@@ -46,6 +46,7 @@ function baseUniq(array, iteratee, comparator) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) { if (isCommon && computed === computed) {
var seenIndex = seen.length; var seenIndex = seen.length;
while (seenIndex--) { while (seenIndex--) {

View File

@@ -1,8 +1,9 @@
import baseHas from './_baseHas';
import castPath from './_castPath'; import castPath from './_castPath';
import has from './has';
import isKey from './_isKey'; import isKey from './_isKey';
import last from './last'; import last from './last';
import parent from './_parent'; import parent from './_parent';
import toKey from './_toKey';
/** /**
* The base implementation of `_.unset`. * The base implementation of `_.unset`.
@@ -15,8 +16,9 @@ import parent from './_parent';
function baseUnset(object, path) { function baseUnset(object, path) {
path = isKey(path, object) ? [path] : castPath(path); path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path); object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true; var key = toKey(last(path));
return !(object != null && baseHas(object, key)) || delete object[key];
} }
export default baseUnset; export default baseUnset;

View File

@@ -1,25 +1,13 @@
import isKeyable from './_isKeyable';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** /**
* Checks if `value` is in `cache`. * Checks if a cache value for `key` exists.
* *
* @private * @private
* @param {Object} cache The set cache to search. * @param {Object} cache The cache to query.
* @param {*} value The value to search for. * @param {string} key The key of the entry to check.
* @returns {number} Returns `true` if `value` is found, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function cacheHas(cache, value) { function cacheHas(cache, key) {
var map = cache.__data__; return cache.has(key);
if (isKeyable(value)) {
var data = map.__data__,
hash = typeof value == 'string' ? data.string : data.hash;
return hash[value] === HASH_UNDEFINED;
}
return map.has(value);
} }
export default cacheHas; export default cacheHas;

View File

@@ -1,27 +0,0 @@
import isKeyable from './_isKeyable';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Adds `value` to the set cache.
*
* @private
* @name push
* @memberOf SetCache
* @param {*} value The value to cache.
*/
function cachePush(value) {
var map = this.__data__;
if (isKeyable(value)) {
var data = map.__data__,
hash = typeof value == 'string' ? data.string : data.hash;
hash[value] = HASH_UNDEFINED;
}
else {
map.set(value, HASH_UNDEFINED);
}
}
export default cachePush;

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/** /**
* Compares values to sort them in ascending order. * Compares values to sort them in ascending order.
* *
@@ -8,22 +10,28 @@
*/ */
function compareAscending(value, other) { function compareAscending(value, other) {
if (value !== other) { if (value !== other) {
var valIsNull = value === null, var valIsDefined = value !== undefined,
valIsUndef = value === undefined, valIsNull = value === null,
valIsReflexive = value === value; valIsReflexive = value === value,
valIsSymbol = isSymbol(value);
var othIsNull = other === null, var othIsDefined = other !== undefined,
othIsUndef = other === undefined, othIsNull = other === null,
othIsReflexive = other === other; othIsReflexive = other === other,
othIsSymbol = isSymbol(other);
if ((value > other && !othIsNull) || !valIsReflexive || if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
(valIsNull && !othIsUndef && othIsReflexive) || (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
(valIsUndef && othIsReflexive)) { (valIsNull && othIsDefined && othIsReflexive) ||
(!valIsDefined && othIsReflexive) ||
!valIsReflexive) {
return 1; return 1;
} }
if ((value < other && !valIsNull) || !othIsReflexive || if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
(othIsNull && !valIsUndef && valIsReflexive) || (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
(othIsUndef && valIsReflexive)) { (othIsNull && valIsDefined && valIsReflexive) ||
(!othIsDefined && valIsReflexive) ||
!othIsReflexive) {
return -1; return -1;
} }
} }

View File

@@ -6,7 +6,7 @@ var nativeMax = Math.max;
* placeholders, and provided arguments into a single array of arguments. * placeholders, and provided arguments into a single array of arguments.
* *
* @private * @private
* @param {Array|Object} args The provided arguments. * @param {Array} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided. * @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function. * @params {boolean} [isCurried] Specify composing for a curried function.

View File

@@ -6,7 +6,7 @@ var nativeMax = Math.max;
* is tailored for `_.partialRight`. * is tailored for `_.partialRight`.
* *
* @private * @private
* @param {Array|Object} args The provided arguments. * @param {Array} args The provided arguments.
* @param {Array} partials The arguments to append to those provided. * @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function. * @params {boolean} [isCurried] Specify composing for a curried function.

View File

@@ -15,7 +15,7 @@ function createAssigner(assigner) {
customizer = length > 1 ? sources[length - 1] : undefined, customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined; guard = length > 2 ? sources[2] : undefined;
customizer = typeof customizer == 'function' customizer = (assigner.length > 3 && typeof customizer == 'function')
? (length--, customizer) ? (length--, customizer)
: undefined; : undefined;

View File

@@ -8,7 +8,7 @@ import toString from './toString';
* *
* @private * @private
* @param {string} methodName The name of the `String` case method to use. * @param {string} methodName The name of the `String` case method to use.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new case function.
*/ */
function createCaseFirst(methodName) { function createCaseFirst(methodName) {
return function(string) { return function(string) {

View File

@@ -2,7 +2,7 @@ import apply from './_apply';
import createCtorWrapper from './_createCtorWrapper'; import createCtorWrapper from './_createCtorWrapper';
import createHybridWrapper from './_createHybridWrapper'; import createHybridWrapper from './_createHybridWrapper';
import createRecurryWrapper from './_createRecurryWrapper'; import createRecurryWrapper from './_createRecurryWrapper';
import getPlaceholder from './_getPlaceholder'; import getHolder from './_getHolder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import root from './_root'; import root from './_root';
@@ -23,7 +23,7 @@ function createCurryWrapper(func, bitmask, arity) {
var length = arguments.length, var length = arguments.length,
args = Array(length), args = Array(length),
index = length, index = length,
placeholder = getPlaceholder(wrapper); placeholder = getHolder(wrapper);
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];

View File

@@ -3,7 +3,7 @@ import composeArgsRight from './_composeArgsRight';
import countHolders from './_countHolders'; import countHolders from './_countHolders';
import createCtorWrapper from './_createCtorWrapper'; import createCtorWrapper from './_createCtorWrapper';
import createRecurryWrapper from './_createRecurryWrapper'; import createRecurryWrapper from './_createRecurryWrapper';
import getPlaceholder from './_getPlaceholder'; import getHolder from './_getHolder';
import reorder from './_reorder'; import reorder from './_reorder';
import replaceHolders from './_replaceHolders'; import replaceHolders from './_replaceHolders';
import root from './_root'; import root from './_root';
@@ -46,14 +46,14 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
index = length, args = Array(length),
args = Array(length); index = length;
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
} }
if (isCurried) { if (isCurried) {
var placeholder = getPlaceholder(wrapper), var placeholder = getHolder(wrapper),
holdersCount = countHolders(args, placeholder); holdersCount = countHolders(args, placeholder);
} }
if (partials) { if (partials) {

View File

@@ -1,3 +1,6 @@
import baseToNumber from './_baseToNumber';
import baseToString from './_baseToString';
/** /**
* Creates a function that performs a mathematical operation on two values. * Creates a function that performs a mathematical operation on two values.
* *
@@ -15,7 +18,17 @@ function createMathOperation(operator) {
result = value; result = value;
} }
if (other !== undefined) { if (other !== undefined) {
result = result === undefined ? other : operator(result, other); if (result === undefined) {
return other;
}
if (typeof value == 'string' || typeof other == 'string') {
value = baseToString(value);
other = baseToString(other);
} else {
value = baseToNumber(value);
other = baseToNumber(other);
}
result = operator(value, other);
} }
return result; return result;
}; };

View File

@@ -12,7 +12,7 @@ import rest from './rest';
* *
* @private * @private
* @param {Function} arrayFunc The function to iterate over iteratees. * @param {Function} arrayFunc The function to iterate over iteratees.
* @returns {Function} Returns the new invoker function. * @returns {Function} Returns the new over function.
*/ */
function createOver(arrayFunc) { function createOver(arrayFunc) {
return rest(function(iteratees) { return rest(function(iteratees) {

View File

@@ -1,4 +1,5 @@
import baseRepeat from './_baseRepeat'; import baseRepeat from './_baseRepeat';
import baseToString from './_baseToString';
import castSlice from './_castSlice'; import castSlice from './_castSlice';
import reHasComplexSymbol from './_reHasComplexSymbol'; import reHasComplexSymbol from './_reHasComplexSymbol';
import stringSize from './_stringSize'; import stringSize from './_stringSize';
@@ -17,7 +18,7 @@ var nativeCeil = Math.ceil;
* @returns {string} Returns the padding for `string`. * @returns {string} Returns the padding for `string`.
*/ */
function createPadding(length, chars) { function createPadding(length, chars) {
chars = chars === undefined ? ' ' : (chars + ''); chars = chars === undefined ? ' ' : baseToString(chars);
var charsLength = chars.length; var charsLength = chars.length;
if (charsLength < 2) { if (charsLength < 2) {

View File

@@ -0,0 +1,20 @@
import toNumber from './toNumber';
/**
* Creates a function that performs a relational operation on two values.
*
* @private
* @param {Function} operator The function to perform the operation.
* @returns {Function} Returns the new relational operation function.
*/
function createRelationalOperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
}
return operator(value, other);
};
}
export default createRelationalOperation;

View File

@@ -1,5 +1,9 @@
import Set from './_Set'; import Set from './_Set';
import noop from './noop'; import noop from './noop';
import setToArray from './_setToArray';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** /**
* Creates a set of `values`. * Creates a set of `values`.
@@ -8,7 +12,7 @@ import noop from './noop';
* @param {Array} values The values to add to the set. * @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set. * @returns {Object} Returns the new set.
*/ */
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) { var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
return new Set(values); return new Set(values);
}; };

30
_createToPairs.js Normal file
View File

@@ -0,0 +1,30 @@
import baseToPairs from './_baseToPairs';
import getTag from './_getTag';
import mapToArray from './_mapToArray';
import setToPairs from './_setToPairs';
/** `Object#toString` result references. */
var mapTag = '[object Map]',
setTag = '[object Set]';
/**
* Creates a `_.toPairs` or `_.toPairsIn` function.
*
* @private
* @param {Function} keysFunc The function to get the keys of a given object.
* @returns {Function} Returns the new pairs function.
*/
function createToPairs(keysFunc) {
return function(object) {
var tag = getTag(object);
if (tag == mapTag) {
return mapToArray(object);
}
if (tag == setTag) {
return setToPairs(object);
}
return baseToPairs(object, keysFunc(object));
};
}
export default createToPairs;

View File

@@ -39,6 +39,7 @@ var nativeMax = Math.max;
* 64 - `_.partialRight` * 64 - `_.partialRight`
* 128 - `_.rearg` * 128 - `_.rearg`
* 256 - `_.ary` * 256 - `_.ary`
* 512 - `_.flip`
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied. * @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [holders] The `partials` placeholder indexes.

View File

@@ -1,3 +1,4 @@
import SetCache from './_SetCache';
import arraySome from './_arraySome'; import arraySome from './_arraySome';
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
@@ -19,9 +20,7 @@ var UNORDERED_COMPARE_FLAG = 1,
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/ */
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
var index = -1, var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
arrLength = array.length, arrLength = array.length,
othLength = other.length; othLength = other.length;
@@ -33,7 +32,10 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
if (stacked) { if (stacked) {
return stacked == other; return stacked == other;
} }
var result = true; var index = -1,
result = true,
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
stack.set(array, other); stack.set(array, other);
// Ignore non-index properties. // Ignore non-index properties.
@@ -54,10 +56,12 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
break; break;
} }
// Recursively compare arrays (susceptible to call stack limits). // Recursively compare arrays (susceptible to call stack limits).
if (isUnordered) { if (seen) {
if (!arraySome(other, function(othValue) { if (!arraySome(other, function(othValue, othIndex) {
return arrValue === othValue || if (!seen.has(othIndex) &&
equalFunc(arrValue, othValue, customizer, bitmask, stack); (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
return seen.add(othIndex);
}
})) { })) {
result = false; result = false;
break; break;

View File

@@ -5,9 +5,9 @@
* @param {Function} func The function to inspect. * @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value. * @returns {*} Returns the placeholder value.
*/ */
function getPlaceholder(func) { function getHolder(func) {
var object = func; var object = func;
return object.placeholder; return object.placeholder;
} }
export default getPlaceholder; export default getHolder;

18
_getMapData.js Normal file
View File

@@ -0,0 +1,18 @@
import isKeyable from './_isKeyable';
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
export default getMapData;

View File

@@ -5,6 +5,7 @@ import isIndex from './_isIndex';
import isKey from './_isKey'; import isKey from './_isKey';
import isLength from './isLength'; import isLength from './isLength';
import isString from './isString'; import isString from './isString';
import toKey from './_toKey';
/** /**
* Checks if `path` exists on `object`. * Checks if `path` exists on `object`.
@@ -23,7 +24,7 @@ function hasPath(object, path, hasFunc) {
length = path.length; length = path.length;
while (++index < length) { while (++index < length) {
var key = path[index]; var key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) { if (!(result = object != null && hasFunc(object, key))) {
break; break;
} }

14
_hashClear.js Normal file
View File

@@ -0,0 +1,14 @@
import nativeCreate from './_nativeCreate';
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
export default hashClear;

View File

@@ -1,15 +1,15 @@
import hashHas from './_hashHas';
/** /**
* Removes `key` and its value from the hash. * Removes `key` and its value from the hash.
* *
* @private * @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify. * @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove. * @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function hashDelete(hash, key) { function hashDelete(key) {
return hashHas(hash, key) && delete hash[key]; return this.has(key) && delete this.__data__[key];
} }
export default hashDelete; export default hashDelete;

View File

@@ -13,16 +13,18 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* Gets the hash value for `key`. * Gets the hash value for `key`.
* *
* @private * @private
* @param {Object} hash The hash to query. * @name get
* @memberOf Hash
* @param {string} key The key of the value to get. * @param {string} key The key of the value to get.
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
function hashGet(hash, key) { function hashGet(key) {
var data = this.__data__;
if (nativeCreate) { if (nativeCreate) {
var result = hash[key]; var result = data[key];
return result === HASH_UNDEFINED ? undefined : result; return result === HASH_UNDEFINED ? undefined : result;
} }
return hasOwnProperty.call(hash, key) ? hash[key] : undefined; return hasOwnProperty.call(data, key) ? data[key] : undefined;
} }
export default hashGet; export default hashGet;

View File

@@ -10,12 +10,14 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* Checks if a hash value for `key` exists. * Checks if a hash value for `key` exists.
* *
* @private * @private
* @param {Object} hash The hash to query. * @name has
* @memberOf Hash
* @param {string} key The key of the entry to check. * @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function hashHas(hash, key) { function hashHas(key) {
return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key); var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
} }
export default hashHas; export default hashHas;

View File

@@ -7,12 +7,16 @@ var HASH_UNDEFINED = '__lodash_hash_undefined__';
* Sets the hash `key` to `value`. * Sets the hash `key` to `value`.
* *
* @private * @private
* @param {Object} hash The hash to modify. * @name set
* @memberOf Hash
* @param {string} key The key of the value to set. * @param {string} key The key of the value to set.
* @param {*} value The value to set. * @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/ */
function hashSet(hash, key, value) { function hashSet(key, value) {
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
} }
export default hashSet; export default hashSet;

View File

@@ -1,6 +1,5 @@
import isArguments from './isArguments'; import isArguments from './isArguments';
import isArray from './isArray'; import isArray from './isArray';
import isArrayLikeObject from './isArrayLikeObject';
/** /**
* Checks if `value` is a flattenable `arguments` object or array. * Checks if `value` is a flattenable `arguments` object or array.
@@ -10,7 +9,7 @@ import isArrayLikeObject from './isArrayLikeObject';
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/ */
function isFlattenable(value) { function isFlattenable(value) {
return isArrayLikeObject(value) && (isArray(value) || isArguments(value)); return isArray(value) || isArguments(value);
} }
export default isFlattenable; export default isFlattenable;

View File

@@ -13,9 +13,10 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/ */
function isIndex(value, length) { function isIndex(value, length) {
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
length = length == null ? MAX_SAFE_INTEGER : length; length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length; return !!length &&
(typeof value == 'number' || reIsUint.test(value)) &&
(value > -1 && value % 1 == 0 && value < length);
} }
export default isIndex; export default isIndex;

View File

@@ -14,13 +14,16 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
* @returns {boolean} Returns `true` if `value` is a property name, else `false`. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/ */
function isKey(value, object) { function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value; var type = typeof value;
if (type == 'number' || type == 'symbol') { if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
return true; return true;
} }
return !isArray(value) && return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object));
(object != null && value in Object(object)));
} }
export default isKey; export default isKey;

View File

@@ -7,8 +7,9 @@
*/ */
function isKeyable(value) { function isKeyable(value) {
var type = typeof value; var type = typeof value;
return type == 'number' || type == 'boolean' || return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
(type == 'string' && value != '__proto__') || value == null; ? (value !== '__proto__')
: (value === null);
} }
export default isKeyable; export default isKeyable;

12
_listCacheClear.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
export default listCacheClear;

View File

@@ -7,25 +7,28 @@ var arrayProto = Array.prototype;
var splice = arrayProto.splice; var splice = arrayProto.splice;
/** /**
* Removes `key` and its value from the associative array. * Removes `key` and its value from the list cache.
* *
* @private * @private
* @param {Array} array The array to modify. * @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove. * @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function assocDelete(array, key) { function listCacheDelete(key) {
var index = assocIndexOf(array, key); var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) { if (index < 0) {
return false; return false;
} }
var lastIndex = array.length - 1; var lastIndex = data.length - 1;
if (index == lastIndex) { if (index == lastIndex) {
array.pop(); data.pop();
} else { } else {
splice.call(array, index, 1); splice.call(data, index, 1);
} }
return true; return true;
} }
export default assocDelete; export default listCacheDelete;

19
_listCacheGet.js Normal file
View File

@@ -0,0 +1,19 @@
import assocIndexOf from './_assocIndexOf';
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
export default listCacheGet;

View File

@@ -1,15 +1,16 @@
import assocIndexOf from './_assocIndexOf'; import assocIndexOf from './_assocIndexOf';
/** /**
* Checks if an associative array value for `key` exists. * Checks if a list cache value for `key` exists.
* *
* @private * @private
* @param {Array} array The array to query. * @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check. * @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function assocHas(array, key) { function listCacheHas(key) {
return assocIndexOf(array, key) > -1; return assocIndexOf(this.__data__, key) > -1;
} }
export default assocHas; export default listCacheHas;

25
_listCacheSet.js Normal file
View File

@@ -0,0 +1,25 @@
import assocIndexOf from './_assocIndexOf';
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
export default listCacheSet;

View File

@@ -1,4 +1,5 @@
import Hash from './_Hash'; import Hash from './_Hash';
import ListCache from './_ListCache';
import Map from './_Map'; import Map from './_Map';
/** /**
@@ -8,12 +9,12 @@ import Map from './_Map';
* @name clear * @name clear
* @memberOf MapCache * @memberOf MapCache
*/ */
function mapClear() { function mapCacheClear() {
this.__data__ = { this.__data__ = {
'hash': new Hash, 'hash': new Hash,
'map': Map ? new Map : [], 'map': new (Map || ListCache),
'string': new Hash 'string': new Hash
}; };
} }
export default mapClear; export default mapCacheClear;

16
_mapCacheDelete.js Normal file
View File

@@ -0,0 +1,16 @@
import getMapData from './_getMapData';
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
export default mapCacheDelete;

16
_mapCacheGet.js Normal file
View File

@@ -0,0 +1,16 @@
import getMapData from './_getMapData';
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
export default mapCacheGet;

16
_mapCacheHas.js Normal file
View File

@@ -0,0 +1,16 @@
import getMapData from './_getMapData';
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
export default mapCacheHas;

18
_mapCacheSet.js Normal file
View File

@@ -0,0 +1,18 @@
import getMapData from './_getMapData';
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
export default mapCacheSet;

View File

@@ -1,23 +0,0 @@
import Map from './_Map';
import assocDelete from './_assocDelete';
import hashDelete from './_hashDelete';
import isKeyable from './_isKeyable';
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapDelete(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashDelete(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map['delete'](key) : assocDelete(data.map, key);
}
export default mapDelete;

View File

@@ -1,23 +0,0 @@
import Map from './_Map';
import assocGet from './_assocGet';
import hashGet from './_hashGet';
import isKeyable from './_isKeyable';
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapGet(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashGet(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.get(key) : assocGet(data.map, key);
}
export default mapGet;

View File

@@ -1,23 +0,0 @@
import Map from './_Map';
import assocHas from './_assocHas';
import hashHas from './_hashHas';
import isKeyable from './_isKeyable';
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapHas(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashHas(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.has(key) : assocHas(data.map, key);
}
export default mapHas;

View File

@@ -1,28 +0,0 @@
import Map from './_Map';
import assocSet from './_assocSet';
import hashSet from './_hashSet';
import isKeyable from './_isKeyable';
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapSet(key, value) {
var data = this.__data__;
if (isKeyable(key)) {
hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
} else if (Map) {
data.map.set(key, value);
} else {
assocSet(data.map, key, value);
}
return this;
}
export default mapSet;

View File

@@ -1,9 +1,9 @@
/** /**
* Converts `map` to an array. * Converts `map` to its key-value pairs.
* *
* @private * @private
* @param {Object} map The map to convert. * @param {Object} map The map to convert.
* @returns {Array} Returns the converted array. * @returns {Array} Returns the key-value pairs.
*/ */
function mapToArray(map) { function mapToArray(map) {
var index = -1, var index = -1,

View File

@@ -5,7 +5,7 @@
* @private * @private
* @param {string} key The key of the property to get. * @param {string} key The key of the property to get.
* @param {*} srcValue The value to match. * @param {*} srcValue The value to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function matchesStrictComparable(key, srcValue) { function matchesStrictComparable(key, srcValue) {
return function(object) { return function(object) {

19
_setCacheAdd.js Normal file
View File

@@ -0,0 +1,19 @@
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Adds `value` to the array cache.
*
* @private
* @name add
* @memberOf SetCache
* @alias push
* @param {*} value The value to cache.
* @returns {Object} Returns the cache instance.
*/
function setCacheAdd(value) {
this.__data__.set(value, HASH_UNDEFINED);
return this;
}
export default setCacheAdd;

14
_setCacheHas.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* Checks if `value` is in the array cache.
*
* @private
* @name has
* @memberOf SetCache
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function setCacheHas(value) {
return this.__data__.has(value);
}
export default setCacheHas;

View File

@@ -1,9 +1,9 @@
/** /**
* Converts `set` to an array. * Converts `set` to an array of its values.
* *
* @private * @private
* @param {Object} set The set to convert. * @param {Object} set The set to convert.
* @returns {Array} Returns the converted array. * @returns {Array} Returns the values.
*/ */
function setToArray(set) { function setToArray(set) {
var index = -1, var index = -1,

18
_setToPairs.js Normal file
View File

@@ -0,0 +1,18 @@
/**
* Converts `set` to its value-value pairs.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the value-value pairs.
*/
function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
}
export default setToPairs;

View File

@@ -1,3 +1,5 @@
import ListCache from './_ListCache';
/** /**
* Removes all key-value entries from the stack. * Removes all key-value entries from the stack.
* *
@@ -6,7 +8,7 @@
* @memberOf Stack * @memberOf Stack
*/ */
function stackClear() { function stackClear() {
this.__data__ = { 'array': [], 'map': null }; this.__data__ = new ListCache;
} }
export default stackClear; export default stackClear;

View File

@@ -1,5 +1,3 @@
import assocDelete from './_assocDelete';
/** /**
* Removes `key` and its value from the stack. * Removes `key` and its value from the stack.
* *
@@ -10,10 +8,7 @@ import assocDelete from './_assocDelete';
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function stackDelete(key) { function stackDelete(key) {
var data = this.__data__, return this.__data__['delete'](key);
array = data.array;
return array ? assocDelete(array, key) : data.map['delete'](key);
} }
export default stackDelete; export default stackDelete;

View File

@@ -1,5 +1,3 @@
import assocGet from './_assocGet';
/** /**
* Gets the stack value for `key`. * Gets the stack value for `key`.
* *
@@ -10,10 +8,7 @@ import assocGet from './_assocGet';
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
function stackGet(key) { function stackGet(key) {
var data = this.__data__, return this.__data__.get(key);
array = data.array;
return array ? assocGet(array, key) : data.map.get(key);
} }
export default stackGet; export default stackGet;

View File

@@ -1,5 +1,3 @@
import assocHas from './_assocHas';
/** /**
* Checks if a stack value for `key` exists. * Checks if a stack value for `key` exists.
* *
@@ -10,10 +8,7 @@ import assocHas from './_assocHas';
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function stackHas(key) { function stackHas(key) {
var data = this.__data__, return this.__data__.has(key);
array = data.array;
return array ? assocHas(array, key) : data.map.has(key);
} }
export default stackHas; export default stackHas;

View File

@@ -1,5 +1,5 @@
import ListCache from './_ListCache';
import MapCache from './_MapCache'; import MapCache from './_MapCache';
import assocSet from './_assocSet';
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
@@ -15,21 +15,11 @@ var LARGE_ARRAY_SIZE = 200;
* @returns {Object} Returns the stack cache instance. * @returns {Object} Returns the stack cache instance.
*/ */
function stackSet(key, value) { function stackSet(key, value) {
var data = this.__data__, var cache = this.__data__;
array = data.array; if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
cache = this.__data__ = new MapCache(cache.__data__);
if (array) {
if (array.length < (LARGE_ARRAY_SIZE - 1)) {
assocSet(array, key, value);
} else {
data.array = null;
data.map = new MapCache(array);
}
}
var map = data.map;
if (map) {
map.set(key, value);
} }
cache.set(key, value);
return this; return this;
} }

View File

@@ -1,5 +1,8 @@
import isSymbol from './isSymbol'; import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** /**
* Converts `value` to a string key if it's not a string or symbol. * Converts `value` to a string key if it's not a string or symbol.
* *
@@ -7,8 +10,12 @@ import isSymbol from './isSymbol';
* @param {*} value The value to inspect. * @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key. * @returns {string|symbol} Returns the key.
*/ */
function toKey(key) { function toKey(value) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + ''); if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
} }
export default toKey; export default toKey;

View File

@@ -11,6 +11,7 @@ import dropWhile from './dropWhile';
import fill from './fill'; import fill from './fill';
import findIndex from './findIndex'; import findIndex from './findIndex';
import findLastIndex from './findLastIndex'; import findLastIndex from './findLastIndex';
import first from './first';
import flatten from './flatten'; import flatten from './flatten';
import flattenDeep from './flattenDeep'; import flattenDeep from './flattenDeep';
import flattenDepth from './flattenDepth'; import flattenDepth from './flattenDepth';
@@ -66,15 +67,15 @@ import zipWith from './zipWith';
export default { export default {
chunk, compact, concat, difference, differenceBy, chunk, compact, concat, difference, differenceBy,
differenceWith, drop, dropRight, dropRightWhile, dropWhile, differenceWith, drop, dropRight, dropRightWhile, dropWhile,
fill, findIndex, findLastIndex, flatten, flattenDeep, fill, findIndex, findLastIndex, first, flatten,
flattenDepth, fromPairs, head, indexOf, initial, flattenDeep, flattenDepth, fromPairs, head, indexOf,
intersection, intersectionBy, intersectionWith, join, last, initial, intersection, intersectionBy, intersectionWith, join,
lastIndexOf, nth, pull, pullAll, pullAllBy, last, lastIndexOf, nth, pull, pullAll,
pullAllWith, pullAt, remove, reverse, slice, pullAllBy, pullAllWith, pullAt, remove, reverse,
sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex,
sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail,
takeRight, takeRightWhile, takeWhile, union, unionBy, take, takeRight, takeRightWhile, takeWhile, union,
unionWith, uniq, uniqBy, uniqWith, unzip, unionBy, unionWith, uniq, uniqBy, uniqWith,
unzipWith, without, xor, xorBy, xorWith, unzip, unzipWith, without, xor, xorBy,
zip, zipObject, zipObjectDeep, zipWith xorWith, zip, zipObject, zipObjectDeep, zipWith
}; };

View File

@@ -11,6 +11,7 @@ export { default as dropWhile } from './dropWhile';
export { default as fill } from './fill'; export { default as fill } from './fill';
export { default as findIndex } from './findIndex'; export { default as findIndex } from './findIndex';
export { default as findLastIndex } from './findLastIndex'; export { default as findLastIndex } from './findLastIndex';
export { default as first } from './first';
export { default as flatten } from './flatten'; export { default as flatten } from './flatten';
export { default as flattenDeep } from './flattenDeep'; export { default as flattenDeep } from './flattenDeep';
export { default as flattenDepth } from './flattenDepth'; export { default as flattenDepth } from './flattenDepth';

2
ary.js
View File

@@ -14,7 +14,7 @@ var ARY_FLAG = 128;
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.
* @param {number} [n=func.length] The arity cap. * @param {number} [n=func.length] The arity cap.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new capped function.
* @example * @example
* *
* _.map(['6', '8', '10'], _.ary(parseInt, 1)); * _.map(['6', '8', '10'], _.ary(parseInt, 1));

View File

@@ -32,6 +32,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @param {Object} object The destination object. * @param {Object} object The destination object.
* @param {...Object} [sources] The source objects. * @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
* @see _.assignIn
* @example * @example
* *
* function Foo() { * function Foo() {

View File

@@ -28,6 +28,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @param {Object} object The destination object. * @param {Object} object The destination object.
* @param {...Object} [sources] The source objects. * @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
* @see _.assign
* @example * @example
* *
* function Foo() { * function Foo() {

View File

@@ -19,6 +19,7 @@ import keysIn from './keysIn';
* @param {...Object} sources The source objects. * @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values. * @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
* @see _.assignWith
* @example * @example
* *
* function customizer(objValue, srcValue) { * function customizer(objValue, srcValue) {

View File

@@ -18,6 +18,7 @@ import keys from './keys';
* @param {...Object} sources The source objects. * @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values. * @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
* @see _.assignInWith
* @example * @example
* *
* function customizer(objValue, srcValue) { * function customizer(objValue, srcValue) {

2
at.js
View File

@@ -11,7 +11,7 @@ import rest from './rest';
* @category Object * @category Object
* @param {Object} object The object to iterate over. * @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick. * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the picked values.
* @example * @example
* *
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };

Some files were not shown because too many files have changed in this diff Show More