mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
11 Commits
4.17.1-es
...
4.17.12-es
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51c827ffd9 | ||
|
|
349273409f | ||
|
|
cc483eda91 | ||
|
|
f73db1f02c | ||
|
|
546e924be3 | ||
|
|
b5a07bdc4b | ||
|
|
ae7044c0d3 | ||
|
|
edff3e8d25 | ||
|
|
528e134995 | ||
|
|
f71a7a04b5 | ||
|
|
035ce4f44c |
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright JS Foundation and other contributors <https://js.foundation/>
|
||||
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||
|
||||
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# lodash-es v4.17.1
|
||||
# lodash-es v4.17.12
|
||||
|
||||
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 ./
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.17.1-es) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.17.12-es) for more details.
|
||||
|
||||
@@ -15,7 +15,9 @@ import initCloneByTag from './_initCloneByTag.js';
|
||||
import initCloneObject from './_initCloneObject.js';
|
||||
import isArray from './isArray.js';
|
||||
import isBuffer from './isBuffer.js';
|
||||
import isMap from './isMap.js';
|
||||
import isObject from './isObject.js';
|
||||
import isSet from './isSet.js';
|
||||
import keys from './keys.js';
|
||||
|
||||
/** Used to compose bitmasks for cloning. */
|
||||
@@ -123,7 +125,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||||
result = initCloneByTag(value, tag, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
@@ -134,6 +136,16 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
|
||||
}
|
||||
stack.set(value, result);
|
||||
|
||||
if (isSet(value)) {
|
||||
value.forEach(function(subValue) {
|
||||
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
||||
});
|
||||
} else if (isMap(value)) {
|
||||
value.forEach(function(subValue, key) {
|
||||
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||||
});
|
||||
}
|
||||
|
||||
var keysFunc = isFull
|
||||
? (isFlat ? getAllKeysIn : getAllKeys)
|
||||
: (isFlat ? keysIn : keys);
|
||||
|
||||
@@ -20,8 +20,7 @@ function baseGetTag(value) {
|
||||
if (value == null) {
|
||||
return value === undefined ? undefinedTag : nullTag;
|
||||
}
|
||||
value = Object(value);
|
||||
return (symToStringTag && symToStringTag in value)
|
||||
return (symToStringTag && symToStringTag in Object(value))
|
||||
? getRawTag(value)
|
||||
: objectToString(value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import baseIsEqualDeep from './_baseIsEqualDeep.js';
|
||||
import isObject from './isObject.js';
|
||||
import isObjectLike from './isObjectLike.js';
|
||||
|
||||
/**
|
||||
@@ -20,7 +19,7 @@ function baseIsEqual(value, other, bitmask, customizer, stack) {
|
||||
if (value === other) {
|
||||
return true;
|
||||
}
|
||||
if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
|
||||
if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
|
||||
return value !== value && other !== other;
|
||||
}
|
||||
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
||||
|
||||
@@ -38,17 +38,12 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
||||
var objIsArr = isArray(object),
|
||||
othIsArr = isArray(other),
|
||||
objTag = arrayTag,
|
||||
othTag = arrayTag;
|
||||
objTag = objIsArr ? arrayTag : getTag(object),
|
||||
othTag = othIsArr ? arrayTag : getTag(other);
|
||||
|
||||
objTag = objTag == argsTag ? objectTag : objTag;
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
|
||||
if (!objIsArr) {
|
||||
objTag = getTag(object);
|
||||
objTag = objTag == argsTag ? objectTag : objTag;
|
||||
}
|
||||
if (!othIsArr) {
|
||||
othTag = getTag(other);
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag,
|
||||
othIsObj = othTag == objectTag,
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
@@ -4,6 +4,7 @@ import baseFor from './_baseFor.js';
|
||||
import baseMergeDeep from './_baseMergeDeep.js';
|
||||
import isObject from './isObject.js';
|
||||
import keysIn from './keysIn.js';
|
||||
import safeGet from './_safeGet.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.merge` without support for multiple sources.
|
||||
@@ -21,13 +22,13 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
return;
|
||||
}
|
||||
baseFor(source, function(srcValue, key) {
|
||||
stack || (stack = new Stack);
|
||||
if (isObject(srcValue)) {
|
||||
stack || (stack = new Stack);
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
}
|
||||
else {
|
||||
var newValue = customizer
|
||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||
? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
if (newValue === undefined) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import isFunction from './isFunction.js';
|
||||
import isObject from './isObject.js';
|
||||
import isPlainObject from './isPlainObject.js';
|
||||
import isTypedArray from './isTypedArray.js';
|
||||
import safeGet from './_safeGet.js';
|
||||
import toPlainObject from './toPlainObject.js';
|
||||
|
||||
/**
|
||||
@@ -29,8 +30,8 @@ import toPlainObject from './toPlainObject.js';
|
||||
* counterparts.
|
||||
*/
|
||||
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
||||
var objValue = object[key],
|
||||
srcValue = source[key],
|
||||
var objValue = safeGet(object, key),
|
||||
srcValue = safeGet(source, key),
|
||||
stacked = stack.get(srcValue);
|
||||
|
||||
if (stacked) {
|
||||
@@ -73,7 +74,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
if (isArguments(objValue)) {
|
||||
newValue = toPlainObject(objValue);
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
else if (!isObject(objValue) || isFunction(objValue)) {
|
||||
newValue = initCloneObject(srcValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import hasIn from './hasIn.js';
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function basePick(object, paths) {
|
||||
object = Object(object);
|
||||
return basePickBy(object, paths, function(value, path) {
|
||||
return hasIn(object, path);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import baseGet from './_baseGet.js';
|
||||
import baseSet from './_baseSet.js';
|
||||
import castPath from './_castPath.js';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||
@@ -20,7 +21,7 @@ function basePickBy(object, paths, predicate) {
|
||||
value = baseGet(object, path);
|
||||
|
||||
if (predicate(value, path)) {
|
||||
baseSet(result, path, value);
|
||||
baseSet(result, castPath(path, object), value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import castPath from './_castPath.js';
|
||||
import baseUnset from './_baseUnset.js';
|
||||
import isIndex from './_isIndex.js';
|
||||
import last from './last.js';
|
||||
import parent from './_parent.js';
|
||||
import toKey from './_toKey.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -29,14 +26,8 @@ function basePullAt(array, indexes) {
|
||||
var previous = index;
|
||||
if (isIndex(index)) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else {
|
||||
var path = castPath(index, array),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
delete object[toKey(last(path))];
|
||||
}
|
||||
} else {
|
||||
baseUnset(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,6 @@ import last from './last.js';
|
||||
import parent from './_parent.js';
|
||||
import toKey from './_toKey.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.unset`.
|
||||
*
|
||||
@@ -20,8 +14,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
function baseUnset(object, path) {
|
||||
path = castPath(path, object);
|
||||
object = parent(object, path);
|
||||
var key = toKey(last(path));
|
||||
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
|
||||
return object == null || delete object[toKey(last(path))];
|
||||
}
|
||||
|
||||
export default baseUnset;
|
||||
|
||||
@@ -5,9 +5,6 @@ import getFuncName from './_getFuncName.js';
|
||||
import isArray from './isArray.js';
|
||||
import isLaziable from './_isLaziable.js';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
@@ -64,8 +61,7 @@ function createFlow(fromRight) {
|
||||
var args = arguments,
|
||||
value = args[0];
|
||||
|
||||
if (wrapper && args.length == 1 &&
|
||||
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
if (wrapper && args.length == 1 && isArray(value)) {
|
||||
return wrapper.plant(value).value();
|
||||
}
|
||||
var index = 0,
|
||||
|
||||
@@ -3,7 +3,8 @@ import toNumber from './toNumber.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
var nativeIsFinite = root.isFinite,
|
||||
nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* Creates a function like `_.round`.
|
||||
@@ -16,8 +17,8 @@ function createRound(methodName) {
|
||||
var func = Math[methodName];
|
||||
return function(number, precision) {
|
||||
number = toNumber(number);
|
||||
precision = nativeMin(toInteger(precision), 292);
|
||||
if (precision) {
|
||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
||||
if (precision && nativeIsFinite(number)) {
|
||||
// Shift with exponential notation to avoid floating-point issues.
|
||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||
var pair = (toString(number) + 'e').split('e'),
|
||||
|
||||
@@ -83,7 +83,7 @@ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arit
|
||||
thisArg = newData[2];
|
||||
partials = newData[3];
|
||||
holders = newData[4];
|
||||
arity = newData[9] = newData[9] == null
|
||||
arity = newData[9] = newData[9] === undefined
|
||||
? (isBindKey ? 0 : func.length)
|
||||
: nativeMax(newData[9] - length, 0);
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ var objectProto = Object.prototype;
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used by `_.defaults` to customize its `_.assignIn` use.
|
||||
* Used by `_.defaults` to customize its `_.assignIn` use to assign properties
|
||||
* of source objects to the destination object for all destination properties
|
||||
* that resolve to `undefined`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} objValue The destination value.
|
||||
@@ -16,7 +18,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* @param {Object} object The parent object of `objValue`.
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function assignInDefaults(objValue, srcValue, key, object) {
|
||||
function customDefaultsAssignIn(objValue, srcValue, key, object) {
|
||||
if (objValue === undefined ||
|
||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
||||
return srcValue;
|
||||
@@ -24,4 +26,4 @@ function assignInDefaults(objValue, srcValue, key, object) {
|
||||
return objValue;
|
||||
}
|
||||
|
||||
export default assignInDefaults;
|
||||
export default customDefaultsAssignIn;
|
||||
@@ -2,7 +2,8 @@ import baseMerge from './_baseMerge.js';
|
||||
import isObject from './isObject.js';
|
||||
|
||||
/**
|
||||
* Used by `_.defaultsDeep` to customize its `_.merge` use.
|
||||
* Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
|
||||
* objects into destination objects that are passed thru.
|
||||
*
|
||||
* @private
|
||||
* @param {*} objValue The destination value.
|
||||
@@ -14,14 +15,14 @@ import isObject from './isObject.js';
|
||||
* counterparts.
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
|
||||
if (isObject(objValue) && isObject(srcValue)) {
|
||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||
stack.set(srcValue, objValue);
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
|
||||
baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
|
||||
stack['delete'](srcValue);
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
export default mergeDefaults;
|
||||
export default customDefaultsMerge;
|
||||
16
_customOmitClone.js
Normal file
16
_customOmitClone.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import isPlainObject from './isPlainObject.js';
|
||||
|
||||
/**
|
||||
* Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
|
||||
* objects.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @param {string} key The key of the property to inspect.
|
||||
* @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
|
||||
*/
|
||||
function customOmitClone(value) {
|
||||
return isPlainObject(value) ? undefined : value;
|
||||
}
|
||||
|
||||
export default customOmitClone;
|
||||
@@ -1,4 +1,4 @@
|
||||
import keys from './keys.js';
|
||||
import getAllKeys from './_getAllKeys.js';
|
||||
|
||||
/** Used to compose bitmasks for value comparisons. */
|
||||
var COMPARE_PARTIAL_FLAG = 1;
|
||||
@@ -24,9 +24,9 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
||||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
|
||||
objProps = keys(object),
|
||||
objProps = getAllKeys(object),
|
||||
objLength = objProps.length,
|
||||
othProps = keys(other),
|
||||
othProps = getAllKeys(other),
|
||||
othLength = othProps.length;
|
||||
|
||||
if (objLength != othLength && !isPartial) {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import overArg from './_overArg.js';
|
||||
import arrayFilter from './_arrayFilter.js';
|
||||
import stubArray from './stubArray.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||||
|
||||
@@ -11,6 +17,14 @@ var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of symbols.
|
||||
*/
|
||||
var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
|
||||
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
|
||||
if (object == null) {
|
||||
return [];
|
||||
}
|
||||
object = Object(object);
|
||||
return arrayFilter(nativeGetSymbols(object), function(symbol) {
|
||||
return propertyIsEnumerable.call(object, symbol);
|
||||
});
|
||||
};
|
||||
|
||||
export default getSymbols;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Used to detect strings that need a more robust regexp to match words. */
|
||||
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
||||
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
||||
|
||||
/**
|
||||
* Checks if `string` contains a word composed of Unicode symbols.
|
||||
|
||||
@@ -17,7 +17,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function hashHas(key) {
|
||||
var data = this.__data__;
|
||||
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
||||
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
|
||||
}
|
||||
|
||||
export default hashHas;
|
||||
|
||||
@@ -13,7 +13,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
*/
|
||||
function initCloneArray(array) {
|
||||
var length = array.length,
|
||||
result = array.constructor(length);
|
||||
result = new array.constructor(length);
|
||||
|
||||
// Add properties assigned by `RegExp#exec`.
|
||||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import cloneArrayBuffer from './_cloneArrayBuffer.js';
|
||||
import cloneDataView from './_cloneDataView.js';
|
||||
import cloneMap from './_cloneMap.js';
|
||||
import cloneRegExp from './_cloneRegExp.js';
|
||||
import cloneSet from './_cloneSet.js';
|
||||
import cloneSymbol from './_cloneSymbol.js';
|
||||
import cloneTypedArray from './_cloneTypedArray.js';
|
||||
|
||||
@@ -32,16 +30,15 @@ var arrayBufferTag = '[object ArrayBuffer]',
|
||||
* Initializes an object clone based on its `toStringTag`.
|
||||
*
|
||||
* **Note:** This function only supports cloning values with tags of
|
||||
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
|
||||
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to clone.
|
||||
* @param {string} tag The `toStringTag` of the object to clone.
|
||||
* @param {Function} cloneFunc The function to clone values.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @returns {Object} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
function initCloneByTag(object, tag, isDeep) {
|
||||
var Ctor = object.constructor;
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
@@ -60,7 +57,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
return cloneTypedArray(object, isDeep);
|
||||
|
||||
case mapTag:
|
||||
return cloneMap(object, isDeep, cloneFunc);
|
||||
return new Ctor;
|
||||
|
||||
case numberTag:
|
||||
case stringTag:
|
||||
@@ -70,7 +67,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
return cloneRegExp(object);
|
||||
|
||||
case setTag:
|
||||
return cloneSet(object, isDeep, cloneFunc);
|
||||
return new Ctor;
|
||||
|
||||
case symbolTag:
|
||||
return cloneSymbol(object);
|
||||
|
||||
@@ -13,10 +13,13 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
var type = typeof value;
|
||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||
|
||||
return !!length &&
|
||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
||||
(value > -1 && value % 1 == 0 && value < length);
|
||||
(type == 'number' ||
|
||||
(type != 'symbol' && reIsUint.test(value))) &&
|
||||
(value > -1 && value % 1 == 0 && value < length);
|
||||
}
|
||||
|
||||
export default isIndex;
|
||||
|
||||
@@ -2,9 +2,6 @@ import baseWrapperValue from './_baseWrapperValue.js';
|
||||
import getView from './_getView.js';
|
||||
import isArray from './isArray.js';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used to indicate the type of lazy iteratees. */
|
||||
var LAZY_FILTER_FLAG = 1,
|
||||
LAZY_MAP_FLAG = 2;
|
||||
@@ -36,8 +33,7 @@ function lazyValue() {
|
||||
resIndex = 0,
|
||||
takeCount = nativeMin(length, this.__takeCount__);
|
||||
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
|
||||
(arrLength == length && takeCount == length)) {
|
||||
if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
|
||||
return baseWrapperValue(array, this.__actions__);
|
||||
}
|
||||
var result = [];
|
||||
|
||||
@@ -15,6 +15,14 @@ var freeProcess = moduleExports && freeGlobal.process;
|
||||
/** Used to access faster Node.js helpers. */
|
||||
var nodeUtil = (function() {
|
||||
try {
|
||||
// Use `util.types` for Node.js 10+.
|
||||
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
||||
|
||||
if (types) {
|
||||
return types;
|
||||
}
|
||||
|
||||
// Legacy `process.binding('util')` for Node.js < 10.
|
||||
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
||||
} catch (e) {}
|
||||
}());
|
||||
|
||||
21
_safeGet.js
Normal file
21
_safeGet.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Gets the value at `key`, unless `key` is "__proto__" or "constructor".
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {string} key The key of the property to get.
|
||||
* @returns {*} Returns the property value.
|
||||
*/
|
||||
function safeGet(object, key) {
|
||||
if (key === 'constructor' && typeof object[key] === 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == '__proto__') {
|
||||
return;
|
||||
}
|
||||
|
||||
return object[key];
|
||||
}
|
||||
|
||||
export default safeGet;
|
||||
@@ -1,8 +1,7 @@
|
||||
import memoizeCapped from './_memoizeCapped.js';
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reLeadingDot = /^\./,
|
||||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||
|
||||
/** Used to match backslashes in property paths. */
|
||||
var reEscapeChar = /\\(\\)?/g;
|
||||
@@ -16,11 +15,11 @@ var reEscapeChar = /\\(\\)?/g;
|
||||
*/
|
||||
var stringToPath = memoizeCapped(function(string) {
|
||||
var result = [];
|
||||
if (reLeadingDot.test(string)) {
|
||||
if (string.charCodeAt(0) === 46 /* . */) {
|
||||
result.push('');
|
||||
}
|
||||
string.replace(rePropName, function(match, number, quote, string) {
|
||||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
|
||||
string.replace(rePropName, function(match, number, quote, subString) {
|
||||
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -38,8 +38,8 @@ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||
reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
|
||||
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
|
||||
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
|
||||
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||
|
||||
|
||||
@@ -108,9 +108,11 @@ function debounce(func, wait, options) {
|
||||
function remainingWait(time) {
|
||||
var timeSinceLastCall = time - lastCallTime,
|
||||
timeSinceLastInvoke = time - lastInvokeTime,
|
||||
result = wait - timeSinceLastCall;
|
||||
timeWaiting = wait - timeSinceLastCall;
|
||||
|
||||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
||||
return maxing
|
||||
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
||||
: timeWaiting;
|
||||
}
|
||||
|
||||
function shouldInvoke(time) {
|
||||
@@ -171,6 +173,7 @@ function debounce(func, wait, options) {
|
||||
}
|
||||
if (maxing) {
|
||||
// Handle invocations in a tight loop.
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return invokeFunc(lastCallTime);
|
||||
}
|
||||
|
||||
44
defaults.js
44
defaults.js
@@ -1,7 +1,13 @@
|
||||
import apply from './_apply.js';
|
||||
import assignInDefaults from './_assignInDefaults.js';
|
||||
import assignInWith from './assignInWith.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import eq from './eq.js';
|
||||
import isIterateeCall from './_isIterateeCall.js';
|
||||
import keysIn from './keysIn.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Assigns own and inherited enumerable string keyed properties of source
|
||||
@@ -24,9 +30,35 @@ import baseRest from './_baseRest.js';
|
||||
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
var defaults = baseRest(function(args) {
|
||||
args.push(undefined, assignInDefaults);
|
||||
return apply(assignInWith, undefined, args);
|
||||
var defaults = baseRest(function(object, sources) {
|
||||
object = Object(object);
|
||||
|
||||
var index = -1;
|
||||
var length = sources.length;
|
||||
var guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
length = 1;
|
||||
}
|
||||
|
||||
while (++index < length) {
|
||||
var source = sources[index];
|
||||
var props = keysIn(source);
|
||||
var propsIndex = -1;
|
||||
var propsLength = props.length;
|
||||
|
||||
while (++propsIndex < propsLength) {
|
||||
var key = props[propsIndex];
|
||||
var value = object[key];
|
||||
|
||||
if (value === undefined ||
|
||||
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
||||
object[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object;
|
||||
});
|
||||
|
||||
export default defaults;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import apply from './_apply.js';
|
||||
import baseRest from './_baseRest.js';
|
||||
import mergeDefaults from './_mergeDefaults.js';
|
||||
import customDefaultsMerge from './_customDefaultsMerge.js';
|
||||
import mergeWith from './mergeWith.js';
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ import mergeWith from './mergeWith.js';
|
||||
* // => { 'a': { 'b': 2, 'c': 3 } }
|
||||
*/
|
||||
var defaultsDeep = baseRest(function(args) {
|
||||
args.push(undefined, mergeDefaults);
|
||||
args.push(undefined, customDefaultsMerge);
|
||||
return apply(mergeWith, undefined, args);
|
||||
});
|
||||
|
||||
|
||||
15
invert.js
15
invert.js
@@ -2,6 +2,16 @@ import constant from './constant.js';
|
||||
import createInverter from './_createInverter.js';
|
||||
import identity from './identity.js';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var nativeObjectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* Creates an object composed of the inverted keys and values of `object`.
|
||||
* If `object` contains duplicate values, subsequent values overwrite
|
||||
@@ -21,6 +31,11 @@ import identity from './identity.js';
|
||||
* // => { '1': 'c', '2': 'b' }
|
||||
*/
|
||||
var invert = createInverter(function(result, value, key) {
|
||||
if (value != null &&
|
||||
typeof value.toString != 'function') {
|
||||
value = nativeObjectToString.call(value);
|
||||
}
|
||||
|
||||
result[value] = key;
|
||||
}, constant(identity));
|
||||
|
||||
|
||||
12
invertBy.js
12
invertBy.js
@@ -7,6 +7,13 @@ var objectProto = Object.prototype;
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var nativeObjectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* This method is like `_.invert` except that the inverted object is generated
|
||||
* from the results of running each element of `object` thru `iteratee`. The
|
||||
@@ -34,6 +41,11 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
|
||||
*/
|
||||
var invertBy = createInverter(function(result, value, key) {
|
||||
if (value != null &&
|
||||
typeof value.toString != 'function') {
|
||||
value = nativeObjectToString.call(value);
|
||||
}
|
||||
|
||||
if (hasOwnProperty.call(result, value)) {
|
||||
result[value].push(key);
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@ import baseIsEqual from './_baseIsEqual.js';
|
||||
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
||||
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
||||
* by their own, not inherited, enumerable properties. Functions and DOM
|
||||
* nodes are **not** supported.
|
||||
* nodes are compared by strict equality, i.e. `===`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @license
|
||||
* Lodash (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="es" -o ./`
|
||||
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
||||
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
@@ -45,7 +45,7 @@ import toInteger from './toInteger.js';
|
||||
import lodash from './wrapperLodash.js';
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.17.1';
|
||||
var VERSION = '4.17.12';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
var WRAP_BIND_KEY_FLAG = 2;
|
||||
@@ -431,14 +431,13 @@ arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'],
|
||||
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
|
||||
arrayEach(['drop', 'take'], function(methodName, index) {
|
||||
LazyWrapper.prototype[methodName] = function(n) {
|
||||
var filtered = this.__filtered__;
|
||||
if (filtered && !index) {
|
||||
return new LazyWrapper(this);
|
||||
}
|
||||
n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
|
||||
|
||||
var result = this.clone();
|
||||
if (filtered) {
|
||||
var result = (this.__filtered__ && !index)
|
||||
? new LazyWrapper(this)
|
||||
: this.clone();
|
||||
|
||||
if (result.__filtered__) {
|
||||
result.__takeCount__ = nativeMin(n, result.__takeCount__);
|
||||
} else {
|
||||
result.__views__.push({
|
||||
@@ -607,10 +606,11 @@ arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(method
|
||||
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
||||
var lodashFunc = lodash[methodName];
|
||||
if (lodashFunc) {
|
||||
var key = (lodashFunc.name + ''),
|
||||
names = realNames[key] || (realNames[key] = []);
|
||||
|
||||
names.push({ 'name': methodName, 'func': lodashFunc });
|
||||
var key = lodashFunc.name + '';
|
||||
if (!hasOwnProperty.call(realNames, key)) {
|
||||
realNames[key] = [];
|
||||
}
|
||||
realNames[key].push({ 'name': methodName, 'func': lodashFunc });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @license
|
||||
* Lodash (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="es" -o ./`
|
||||
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
||||
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
|
||||
11
omit.js
11
omit.js
@@ -3,6 +3,7 @@ import baseClone from './_baseClone.js';
|
||||
import baseUnset from './_baseUnset.js';
|
||||
import castPath from './_castPath.js';
|
||||
import copyObject from './_copyObject.js';
|
||||
import customOmitClone from './_customOmitClone.js';
|
||||
import flatRest from './_flatRest.js';
|
||||
import getAllKeysIn from './_getAllKeysIn.js';
|
||||
|
||||
@@ -36,16 +37,16 @@ var omit = flatRest(function(object, paths) {
|
||||
if (object == null) {
|
||||
return result;
|
||||
}
|
||||
var bitmask = CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG;
|
||||
var isDeep = false;
|
||||
paths = arrayMap(paths, function(path) {
|
||||
path = castPath(path, object);
|
||||
bitmask |= (path.length > 1 ? CLONE_DEEP_FLAG : 0);
|
||||
isDeep || (isDeep = path.length > 1);
|
||||
return path;
|
||||
});
|
||||
|
||||
copyObject(object, getAllKeysIn(object), result);
|
||||
result = baseClone(result, bitmask);
|
||||
|
||||
if (isDeep) {
|
||||
result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
|
||||
}
|
||||
var length = paths.length;
|
||||
while (length--) {
|
||||
baseUnset(result, paths[length]);
|
||||
|
||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lodash-es",
|
||||
"version": "4.17.1",
|
||||
"version": "4.17.12",
|
||||
"description": "Lodash exported as ES modules.",
|
||||
"keywords": "es6, modules, stdlib, util",
|
||||
"homepage": "https://lodash.com/custom-builds",
|
||||
@@ -10,11 +10,12 @@
|
||||
"jsnext:main": "lodash.js",
|
||||
"main": "lodash.js",
|
||||
"module": "lodash.js",
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"sideEffects": false,
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com>",
|
||||
"contributors": [
|
||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
|
||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
||||
"John-David Dalton <john.david.dalton@gmail.com>",
|
||||
"Mathias Bynens <mathias@qiwi.be>"
|
||||
],
|
||||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
|
||||
"type": "module",
|
||||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash-archive/lodash-cli for testing details.\"" }
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ function result(object, path, defaultValue) {
|
||||
|
||||
// Ensure the loop is entered when path is empty.
|
||||
if (!length) {
|
||||
object = undefined;
|
||||
length = 1;
|
||||
object = undefined;
|
||||
}
|
||||
while (++index < length) {
|
||||
var value = object == null ? undefined : object[toKey(path[index])];
|
||||
|
||||
@@ -48,18 +48,14 @@ function spread(func, start) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
||||
start = start == null ? 0 : nativeMax(toInteger(start), 0);
|
||||
return baseRest(function(args) {
|
||||
var array = args[start],
|
||||
lastIndex = args.length - 1,
|
||||
otherArgs = castSlice(args, 0, start);
|
||||
|
||||
if (array) {
|
||||
arrayPush(otherArgs, array);
|
||||
}
|
||||
if (start != lastIndex) {
|
||||
arrayPush(otherArgs, castSlice(args, start + 1));
|
||||
}
|
||||
return apply(func, this, otherArgs);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ import toString from './toString.js';
|
||||
*/
|
||||
function startsWith(string, target, position) {
|
||||
string = toString(string);
|
||||
position = baseClamp(toInteger(position), 0, string.length);
|
||||
position = position == null
|
||||
? 0
|
||||
: baseClamp(toInteger(position), 0, string.length);
|
||||
|
||||
target = baseToString(target);
|
||||
return string.slice(position, position + target.length) == target;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import baseWhile from './_baseWhile.js';
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'active': false },
|
||||
* { 'user': 'fred', 'active': false},
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': true }
|
||||
* ];
|
||||
*
|
||||
|
||||
25
template.js
25
template.js
@@ -1,7 +1,7 @@
|
||||
import assignInDefaults from './_assignInDefaults.js';
|
||||
import assignInWith from './assignInWith.js';
|
||||
import attempt from './attempt.js';
|
||||
import baseValues from './_baseValues.js';
|
||||
import customDefaultsAssignIn from './_customDefaultsAssignIn.js';
|
||||
import escapeStringChar from './_escapeStringChar.js';
|
||||
import isError from './isError.js';
|
||||
import isIterateeCall from './_isIterateeCall.js';
|
||||
@@ -27,6 +27,12 @@ var reNoMatch = /($^)/;
|
||||
/** Used to match unescaped characters in compiled string literals. */
|
||||
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Creates a compiled template function that can interpolate data properties
|
||||
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
||||
@@ -141,9 +147,9 @@ function template(string, options, guard) {
|
||||
options = undefined;
|
||||
}
|
||||
string = toString(string);
|
||||
options = assignInWith({}, options, settings, assignInDefaults);
|
||||
options = assignInWith({}, options, settings, customDefaultsAssignIn);
|
||||
|
||||
var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
|
||||
var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
|
||||
importsKeys = keys(imports),
|
||||
importsValues = baseValues(imports, importsKeys);
|
||||
|
||||
@@ -162,7 +168,14 @@ function template(string, options, guard) {
|
||||
, 'g');
|
||||
|
||||
// Use a sourceURL for easier debugging.
|
||||
var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : '';
|
||||
// The sourceURL gets injected into the source that's eval-ed, so be careful
|
||||
// with lookup (in case of e.g. prototype pollution), and strip newlines if any.
|
||||
// A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
|
||||
var sourceURL = hasOwnProperty.call(options, 'sourceURL')
|
||||
? ('//# sourceURL=' +
|
||||
(options.sourceURL + '').replace(/[\r\n]/g, ' ') +
|
||||
'\n')
|
||||
: '';
|
||||
|
||||
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
||||
interpolateValue || (interpolateValue = esTemplateValue);
|
||||
@@ -193,7 +206,9 @@ function template(string, options, guard) {
|
||||
|
||||
// If `variable` is not specified wrap a with-statement around the generated
|
||||
// code to add the data object to the top of the scope chain.
|
||||
var variable = options.variable;
|
||||
// Like with sourceURL, we take care to not check the option's prototype,
|
||||
// as this configuration is a code injection vector.
|
||||
var variable = hasOwnProperty.call(options, 'variable') && options.variable;
|
||||
if (!variable) {
|
||||
source = 'with (obj) {\n' + source + '\n}\n';
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import reInterpolate from './_reInterpolate.js';
|
||||
|
||||
/**
|
||||
* By default, the template delimiters used by lodash are like those in
|
||||
* embedded Ruby (ERB). Change the following template settings to use
|
||||
* alternative delimiters.
|
||||
* embedded Ruby (ERB) as well as ES2015 template strings. Change the
|
||||
* following template settings to use alternative delimiters.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -29,7 +29,9 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
||||
* // => 3
|
||||
*/
|
||||
function toSafeInteger(value) {
|
||||
return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
|
||||
return value
|
||||
? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
|
||||
: (value === 0 ? value : 0);
|
||||
}
|
||||
|
||||
export default toSafeInteger;
|
||||
|
||||
@@ -29,9 +29,9 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* Shortcut fusion is an optimization to merge iteratee calls; this avoids
|
||||
* the creation of intermediate arrays and can greatly reduce the number of
|
||||
* iteratee executions. Sections of a chain sequence qualify for shortcut
|
||||
* fusion if the section is applied to an array of at least `200` elements
|
||||
* and any iteratees accept only one argument. The heuristic for whether a
|
||||
* section qualifies for shortcut fusion is subject to change.
|
||||
* fusion if the section is applied to an array and iteratees accept only
|
||||
* one argument. The heuristic for whether a section qualifies for shortcut
|
||||
* fusion is subject to change.
|
||||
*
|
||||
* Chaining is supported in custom builds as long as the `_#value` method is
|
||||
* directly or indirectly included in the build.
|
||||
|
||||
Reference in New Issue
Block a user