From c7a7540e16ff88d686bdfecd6d206e7bdd74386a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 19 Dec 2016 17:17:56 -0600 Subject: [PATCH] Bump to v4.17.3. --- README.md | 4 +- _baseGetTag.js | 3 +- _baseIsEqual.js | 4 +- _baseIsEqualDeep.js | 15 +- _basePick.js | 1 - _createFlow.js | 6 +- _createRound.js | 2 +- _createWrap.js | 2 +- ...nDefaults.js => _customDefaultsAssignIn.js | 8 +- _mergeDefaults.js => _customDefaultsMerge.js | 9 +- _customOmitClone.js | 20 ++ _equalObjects.js | 6 +- _getSymbols.js | 18 +- _hashHas.js | 2 +- _lazyValue.js | 6 +- defaults.js | 4 +- defaultsDeep.js | 4 +- isEqual.js | 2 +- main.js | 193 ++++++++++-------- omit.js | 4 +- package.json | 2 +- spread.js | 5 +- startsWith.js | 5 +- takeWhile.js | 2 +- template.js | 6 +- templateSettings.js | 4 +- toSafeInteger.js | 4 +- wrapperLodash.js | 6 +- 28 files changed, 195 insertions(+), 152 deletions(-) rename _assignInDefaults.js => _customDefaultsAssignIn.js (72%) rename _mergeDefaults.js => _customDefaultsMerge.js (72%) create mode 100644 _customOmitClone.js diff --git a/README.md b/README.md index 2b8e1fb54..71e6efee7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-amd v4.17.2 +# lodash-amd v4.17.3 The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. @@ -27,4 +27,4 @@ require({ }); ``` -See the [package source](https://github.com/lodash/lodash/tree/4.17.2-amd) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.17.3-amd) for more details. diff --git a/_baseGetTag.js b/_baseGetTag.js index e75dfd132..66be4e4aa 100644 --- a/_baseGetTag.js +++ b/_baseGetTag.js @@ -21,8 +21,7 @@ define(['./_Symbol', './_getRawTag', './_objectToString'], function(Symbol, getR 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); } diff --git a/_baseIsEqual.js b/_baseIsEqual.js index 51a34a2ca..20dd0e86e 100644 --- a/_baseIsEqual.js +++ b/_baseIsEqual.js @@ -1,4 +1,4 @@ -define(['./_baseIsEqualDeep', './isObject', './isObjectLike'], function(baseIsEqualDeep, isObject, isObjectLike) { +define(['./_baseIsEqualDeep', './isObjectLike'], function(baseIsEqualDeep, isObjectLike) { /** * The base implementation of `_.isEqual` which supports partial comparisons @@ -18,7 +18,7 @@ define(['./_baseIsEqualDeep', './isObject', './isObjectLike'], function(baseIsEq 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); diff --git a/_baseIsEqualDeep.js b/_baseIsEqualDeep.js index bfa76075d..58f6a32dc 100644 --- a/_baseIsEqualDeep.js +++ b/_baseIsEqualDeep.js @@ -31,17 +31,12 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge 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; diff --git a/_basePick.js b/_basePick.js index f2946a09f..a8acb0158 100644 --- a/_basePick.js +++ b/_basePick.js @@ -10,7 +10,6 @@ define(['./_basePickBy', './hasIn'], function(basePickBy, hasIn) { * @returns {Object} Returns the new object. */ function basePick(object, paths) { - object = Object(object); return basePickBy(object, paths, function(value, path) { return hasIn(object, path); }); diff --git a/_createFlow.js b/_createFlow.js index d400f6768..3b122e5eb 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -3,9 +3,6 @@ define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './is /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; - /** Used as the size to enable large array optimizations. */ - var LARGE_ARRAY_SIZE = 200; - /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -62,8 +59,7 @@ define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './is 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, diff --git a/_createRound.js b/_createRound.js index 8feb684d0..b4ec0b086 100644 --- a/_createRound.js +++ b/_createRound.js @@ -14,7 +14,7 @@ define(['./toInteger', './toNumber', './toString'], function(toInteger, toNumber var func = Math[methodName]; return function(number, precision) { number = toNumber(number); - precision = nativeMin(toInteger(precision), 292); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); if (precision) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. diff --git a/_createWrap.js b/_createWrap.js index 38cbe4cc5..ffc0904ed 100644 --- a/_createWrap.js +++ b/_createWrap.js @@ -77,7 +77,7 @@ define(['./_baseSetData', './_createBind', './_createCurry', './_createHybrid', 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); diff --git a/_assignInDefaults.js b/_customDefaultsAssignIn.js similarity index 72% rename from _assignInDefaults.js rename to _customDefaultsAssignIn.js index 3761bba22..9080ef8e0 100644 --- a/_assignInDefaults.js +++ b/_customDefaultsAssignIn.js @@ -10,7 +10,9 @@ define(['./eq'], function(eq) { 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. @@ -19,7 +21,7 @@ define(['./eq'], function(eq) { * @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; @@ -27,5 +29,5 @@ define(['./eq'], function(eq) { return objValue; } - return assignInDefaults; + return customDefaultsAssignIn; }); diff --git a/_mergeDefaults.js b/_customDefaultsMerge.js similarity index 72% rename from _mergeDefaults.js rename to _customDefaultsMerge.js index c4c6dc25b..0b6b8592e 100644 --- a/_mergeDefaults.js +++ b/_customDefaultsMerge.js @@ -4,7 +4,8 @@ define(['./_baseMerge', './isObject'], function(baseMerge, isObject) { var undefined; /** - * 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. @@ -16,15 +17,15 @@ define(['./_baseMerge', './isObject'], function(baseMerge, isObject) { * 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; } - return mergeDefaults; + return customDefaultsMerge; }); diff --git a/_customOmitClone.js b/_customOmitClone.js new file mode 100644 index 000000000..aaddde388 --- /dev/null +++ b/_customOmitClone.js @@ -0,0 +1,20 @@ +define(['./isPlainObject'], function(isPlainObject) { + + /** Used as a safe reference for `undefined` in pre-ES5 environments. */ + var undefined; + + /** + * 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, key) { + return (key !== undefined && isPlainObject(value)) ? undefined : value; + } + + return customOmitClone; +}); diff --git a/_equalObjects.js b/_equalObjects.js index ec7bd4d16..c1eba21fc 100644 --- a/_equalObjects.js +++ b/_equalObjects.js @@ -1,4 +1,4 @@ -define(['./keys'], function(keys) { +define(['./_getAllKeys'], function(getAllKeys) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -27,9 +27,9 @@ define(['./keys'], function(keys) { */ 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) { diff --git a/_getSymbols.js b/_getSymbols.js index 50a9e4fce..7134e6127 100644 --- a/_getSymbols.js +++ b/_getSymbols.js @@ -1,4 +1,10 @@ -define(['./_overArg', './stubArray'], function(overArg, stubArray) { +define(['./_arrayFilter', './stubArray'], function(arrayFilter, stubArray) { + + /** 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; @@ -10,7 +16,15 @@ define(['./_overArg', './stubArray'], function(overArg, stubArray) { * @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); + }); + }; return getSymbols; }); diff --git a/_hashHas.js b/_hashHas.js index 572f4bff9..b4c8db435 100644 --- a/_hashHas.js +++ b/_hashHas.js @@ -20,7 +20,7 @@ define(['./_nativeCreate'], function(nativeCreate) { */ 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); } return hashHas; diff --git a/_lazyValue.js b/_lazyValue.js index 2903bb0a0..07a1248a6 100644 --- a/_lazyValue.js +++ b/_lazyValue.js @@ -1,8 +1,5 @@ define(['./_baseWrapperValue', './_getView', './isArray'], function(baseWrapperValue, getView, isArray) { - /** 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; @@ -34,8 +31,7 @@ define(['./_baseWrapperValue', './_getView', './isArray'], function(baseWrapperV 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 = []; diff --git a/defaults.js b/defaults.js index 5d661a5fd..c536f7701 100644 --- a/defaults.js +++ b/defaults.js @@ -1,4 +1,4 @@ -define(['./_apply', './_assignInDefaults', './assignInWith', './_baseRest'], function(apply, assignInDefaults, assignInWith, baseRest) { +define(['./_apply', './assignInWith', './_baseRest', './_customDefaultsAssignIn'], function(apply, assignInWith, baseRest, customDefaultsAssignIn) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -25,7 +25,7 @@ define(['./_apply', './_assignInDefaults', './assignInWith', './_baseRest'], fun * // => { 'a': 1, 'b': 2 } */ var defaults = baseRest(function(args) { - args.push(undefined, assignInDefaults); + args.push(undefined, customDefaultsAssignIn); return apply(assignInWith, undefined, args); }); diff --git a/defaultsDeep.js b/defaultsDeep.js index 51eba8f4f..bd309e473 100644 --- a/defaultsDeep.js +++ b/defaultsDeep.js @@ -1,4 +1,4 @@ -define(['./_apply', './_baseRest', './_mergeDefaults', './mergeWith'], function(apply, baseRest, mergeDefaults, mergeWith) { +define(['./_apply', './_baseRest', './_customDefaultsMerge', './mergeWith'], function(apply, baseRest, customDefaultsMerge, mergeWith) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -23,7 +23,7 @@ define(['./_apply', './_baseRest', './_mergeDefaults', './mergeWith'], function( * // => { 'a': { 'b': 2, 'c': 3 } } */ var defaultsDeep = baseRest(function(args) { - args.push(undefined, mergeDefaults); + args.push(undefined, customDefaultsMerge); return apply(mergeWith, undefined, args); }); diff --git a/isEqual.js b/isEqual.js index 605e44613..99b2b4a3c 100644 --- a/isEqual.js +++ b/isEqual.js @@ -8,7 +8,7 @@ define(['./_baseIsEqual'], function(baseIsEqual) { * 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 _ diff --git a/main.js b/main.js index dc0fa9634..65e543c34 100644 --- a/main.js +++ b/main.js @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.2'; + var VERSION = '4.17.3'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -1568,9 +1568,9 @@ * 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. @@ -1729,8 +1729,8 @@ /** * 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 _ @@ -1877,8 +1877,7 @@ 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 = []; @@ -1992,7 +1991,7 @@ */ 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); } /** @@ -2465,24 +2464,6 @@ return shuffleSelf(copyArray(array)); } - /** - * Used by `_.defaults` to customize its `_.assignIn` use. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to assign. - * @param {Object} object The parent object of `objValue`. - * @returns {*} Returns the value to assign. - */ - function assignInDefaults(objValue, srcValue, key, object) { - if (objValue === undefined || - (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { - return srcValue; - } - return objValue; - } - /** * This function is like `assignValue` except that it doesn't assign * `undefined` values. @@ -3095,8 +3076,7 @@ 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); } @@ -3300,7 +3280,7 @@ 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); @@ -3323,17 +3303,12 @@ 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; @@ -3781,7 +3756,6 @@ * @returns {Object} Returns the new object. */ function basePick(object, paths) { - object = Object(object); return basePickBy(object, paths, function(value, path) { return hasIn(object, path); }); @@ -5174,8 +5148,7 @@ 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, @@ -5482,7 +5455,7 @@ var func = Math[methodName]; return function(number, precision) { number = toNumber(number); - precision = nativeMin(toInteger(precision), 292); + precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); if (precision) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. @@ -5587,7 +5560,7 @@ 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); @@ -5607,6 +5580,63 @@ return setWrapToString(setter(result, newData), func, bitmask); } + /** + * 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. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ + function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || + (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { + return srcValue; + } + return objValue; + } + + /** + * 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. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. + */ + 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, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; + } + + /** + * 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, key) { + return (key !== undefined && isPlainObject(value)) ? undefined : value; + } + /** * A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. @@ -5778,9 +5808,9 @@ */ 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) { @@ -6018,7 +6048,15 @@ * @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); + }); + }; /** * Creates an array of the own and inherited enumerable symbols of `object`. @@ -6504,29 +6542,6 @@ return data; } - /** - * Used by `_.defaultsDeep` to customize its `_.merge` use. - * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to merge. - * @param {Object} object The parent object of `objValue`. - * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - * @returns {*} Returns the value to assign. - */ - function mergeDefaults(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); - stack['delete'](srcValue); - } - return objValue; - } - /** * This function is like * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) @@ -8269,7 +8284,7 @@ * * var users = [ * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false}, + * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': true } * ]; * @@ -10838,7 +10853,7 @@ 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], otherArgs = castSlice(args, 0, start); @@ -11508,7 +11523,7 @@ * 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 _ @@ -12528,7 +12543,9 @@ * // => 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); } /** @@ -12782,7 +12799,7 @@ * // => { 'a': 1, 'b': 2 } */ var defaults = baseRest(function(args) { - args.push(undefined, assignInDefaults); + args.push(undefined, customDefaultsAssignIn); return apply(assignInWith, undefined, args); }); @@ -12806,7 +12823,7 @@ * // => { 'a': { 'b': 2, 'c': 3 } } */ var defaultsDeep = baseRest(function(args) { - args.push(undefined, mergeDefaults); + args.push(undefined, customDefaultsMerge); return apply(mergeWith, undefined, args); }); @@ -13468,7 +13485,7 @@ }); copyObject(object, getAllKeysIn(object), result); if (isDeep) { - result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG); + result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); } var length = paths.length; while (length--) { @@ -14617,7 +14634,10 @@ */ 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; } @@ -14736,9 +14756,9 @@ 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); @@ -16822,14 +16842,13 @@ // 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({ diff --git a/omit.js b/omit.js index ed4784f27..303c7adca 100644 --- a/omit.js +++ b/omit.js @@ -1,4 +1,4 @@ -define(['./_arrayMap', './_baseClone', './_baseUnset', './_castPath', './_copyObject', './_flatRest', './_getAllKeysIn'], function(arrayMap, baseClone, baseUnset, castPath, copyObject, flatRest, getAllKeysIn) { +define(['./_arrayMap', './_baseClone', './_baseUnset', './_castPath', './_copyObject', './_customOmitClone', './_flatRest', './_getAllKeysIn'], function(arrayMap, baseClone, baseUnset, castPath, copyObject, customOmitClone, flatRest, getAllKeysIn) { /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, @@ -38,7 +38,7 @@ define(['./_arrayMap', './_baseClone', './_baseUnset', './_castPath', './_copyOb }); copyObject(object, getAllKeysIn(object), result); if (isDeep) { - result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG); + result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); } var length = paths.length; while (length--) { diff --git a/package.json b/package.json index 2746bbc9b..501d7dde5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-amd", - "version": "4.17.2", + "version": "4.17.3", "description": "Lodash exported as AMD modules.", "keywords": "amd, modules, stdlib, util", "homepage": "https://lodash.com/custom-builds", diff --git a/spread.js b/spread.js index d4e6b8c72..cfc72c8d7 100644 --- a/spread.js +++ b/spread.js @@ -1,8 +1,5 @@ define(['./_apply', './_arrayPush', './_baseRest', './_castSlice', './toInteger'], function(apply, arrayPush, baseRest, castSlice, toInteger) { - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; - /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -47,7 +44,7 @@ define(['./_apply', './_arrayPush', './_baseRest', './_castSlice', './toInteger' 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], otherArgs = castSlice(args, 0, start); diff --git a/startsWith.js b/startsWith.js index 8bcefd6f6..8ca68aa6d 100644 --- a/startsWith.js +++ b/startsWith.js @@ -25,7 +25,10 @@ define(['./_baseClamp', './_baseToString', './toInteger', './toString'], functio */ 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; } diff --git a/takeWhile.js b/takeWhile.js index 134c4234d..15239b70c 100644 --- a/takeWhile.js +++ b/takeWhile.js @@ -16,7 +16,7 @@ define(['./_baseIteratee', './_baseWhile'], function(baseIteratee, baseWhile) { * * var users = [ * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false}, + * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': true } * ]; * diff --git a/template.js b/template.js index 5657c599c..b0052721a 100644 --- a/template.js +++ b/template.js @@ -1,4 +1,4 @@ -define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', './_escapeStringChar', './isError', './_isIterateeCall', './keys', './_reInterpolate', './templateSettings', './toString'], function(assignInDefaults, assignInWith, attempt, baseValues, escapeStringChar, isError, isIterateeCall, keys, reInterpolate, templateSettings, toString) { +define(['./assignInWith', './attempt', './_baseValues', './_customDefaultsAssignIn', './_escapeStringChar', './isError', './_isIterateeCall', './keys', './_reInterpolate', './templateSettings', './toString'], function(assignInWith, attempt, baseValues, customDefaultsAssignIn, escapeStringChar, isError, isIterateeCall, keys, reInterpolate, templateSettings, toString) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -134,9 +134,9 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', ' 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); diff --git a/templateSettings.js b/templateSettings.js index 64d182261..e3bb5019e 100644 --- a/templateSettings.js +++ b/templateSettings.js @@ -2,8 +2,8 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio /** * 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 _ diff --git a/toSafeInteger.js b/toSafeInteger.js index 1de6b9101..007760ed4 100644 --- a/toSafeInteger.js +++ b/toSafeInteger.js @@ -28,7 +28,9 @@ define(['./_baseClamp', './toInteger'], function(baseClamp, toInteger) { * // => 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); } return toSafeInteger; diff --git a/wrapperLodash.js b/wrapperLodash.js index 040b45dc6..77677bb2b 100644 --- a/wrapperLodash.js +++ b/wrapperLodash.js @@ -24,9 +24,9 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseLodash', './isArray', './i * 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.