diff --git a/README.md b/README.md index c2a951fed..4f5bc8d81 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-es v4.17.2 +# lodash-es v4.17.3 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.2-es) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.17.3-es) for more details. diff --git a/_baseGetTag.js b/_baseGetTag.js index 8e9663176..61b440a06 100644 --- a/_baseGetTag.js +++ b/_baseGetTag.js @@ -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); } diff --git a/_baseIsEqual.js b/_baseIsEqual.js index 67f274118..3b5aba815 100644 --- a/_baseIsEqual.js +++ b/_baseIsEqual.js @@ -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); diff --git a/_baseIsEqualDeep.js b/_baseIsEqualDeep.js index aa8bd25da..d8c8bf075 100644 --- a/_baseIsEqualDeep.js +++ b/_baseIsEqualDeep.js @@ -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; diff --git a/_basePick.js b/_basePick.js index be2da0e44..bf80ff0f4 100644 --- a/_basePick.js +++ b/_basePick.js @@ -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); }); diff --git a/_createFlow.js b/_createFlow.js index 70ce17fcc..8e9708469 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -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, diff --git a/_createRound.js b/_createRound.js index ab9ec8da7..8b3edab7b 100644 --- a/_createRound.js +++ b/_createRound.js @@ -16,7 +16,7 @@ function createRound(methodName) { 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 c306ded74..6b05382b7 100644 --- a/_createWrap.js +++ b/_createWrap.js @@ -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); diff --git a/_assignInDefaults.js b/_customDefaultsAssignIn.js similarity index 68% rename from _assignInDefaults.js rename to _customDefaultsAssignIn.js index cfee5ac67..0de9339b2 100644 --- a/_assignInDefaults.js +++ b/_customDefaultsAssignIn.js @@ -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; diff --git a/_mergeDefaults.js b/_customDefaultsMerge.js similarity index 69% rename from _mergeDefaults.js rename to _customDefaultsMerge.js index 1e3b7b5a1..63c21c88b 100644 --- a/_mergeDefaults.js +++ b/_customDefaultsMerge.js @@ -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; diff --git a/_customOmitClone.js b/_customOmitClone.js new file mode 100644 index 000000000..40b5856cc --- /dev/null +++ b/_customOmitClone.js @@ -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, key) { + return (key !== undefined && isPlainObject(value)) ? undefined : value; +} + +export default customOmitClone; diff --git a/_equalObjects.js b/_equalObjects.js index da70dc469..9f304ab7a 100644 --- a/_equalObjects.js +++ b/_equalObjects.js @@ -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) { diff --git a/_getSymbols.js b/_getSymbols.js index 801893a9a..474442abc 100644 --- a/_getSymbols.js +++ b/_getSymbols.js @@ -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; diff --git a/_hashHas.js b/_hashHas.js index 8de3daad2..6db025d8e 100644 --- a/_hashHas.js +++ b/_hashHas.js @@ -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; diff --git a/_lazyValue.js b/_lazyValue.js index 1eac26965..ca2e011d4 100644 --- a/_lazyValue.js +++ b/_lazyValue.js @@ -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 = []; diff --git a/defaults.js b/defaults.js index a460e454a..b27d8818f 100644 --- a/defaults.js +++ b/defaults.js @@ -1,7 +1,7 @@ import apply from './_apply.js'; -import assignInDefaults from './_assignInDefaults.js'; import assignInWith from './assignInWith.js'; import baseRest from './_baseRest.js'; +import customDefaultsAssignIn from './_customDefaultsAssignIn.js'; /** * Assigns own and inherited enumerable string keyed properties of source @@ -25,7 +25,7 @@ import baseRest from './_baseRest.js'; * // => { '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 10863925e..409383e8f 100644 --- a/defaultsDeep.js +++ b/defaultsDeep.js @@ -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); }); diff --git a/isEqual.js b/isEqual.js index 2494fa68e..8be0e2ce5 100644 --- a/isEqual.js +++ b/isEqual.js @@ -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 _ diff --git a/lodash.default.js b/lodash.default.js index 159824daf..e33e8d162 100644 --- a/lodash.default.js +++ b/lodash.default.js @@ -45,7 +45,7 @@ import toInteger from './toInteger.js'; import lodash from './wrapperLodash.js'; /** Used as the semantic version number. */ -var VERSION = '4.17.2'; +var VERSION = '4.17.3'; /** 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({ diff --git a/omit.js b/omit.js index f23a9ca4a..4657d0c3a 100644 --- a/omit.js +++ b/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'; @@ -44,7 +45,7 @@ var omit = flatRest(function(object, paths) { }); 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 7cdba41ab..a4459d54a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-es", - "version": "4.17.2", + "version": "4.17.3", "description": "Lodash exported as ES modules.", "keywords": "es6, modules, stdlib, util", "homepage": "https://lodash.com/custom-builds", diff --git a/spread.js b/spread.js index cf221cfc9..3fb8b2388 100644 --- a/spread.js +++ b/spread.js @@ -48,7 +48,7 @@ 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], otherArgs = castSlice(args, 0, start); diff --git a/startsWith.js b/startsWith.js index 991da7a2d..19ca033fe 100644 --- a/startsWith.js +++ b/startsWith.js @@ -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; } diff --git a/takeWhile.js b/takeWhile.js index a1a794d1b..f220a6e5e 100644 --- a/takeWhile.js +++ b/takeWhile.js @@ -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 } * ]; * diff --git a/template.js b/template.js index 07d32c67c..17873472c 100644 --- a/template.js +++ b/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'; @@ -141,9 +141,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); diff --git a/templateSettings.js b/templateSettings.js index ed9388448..5fe73e97a 100644 --- a/templateSettings.js +++ b/templateSettings.js @@ -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 _ diff --git a/toSafeInteger.js b/toSafeInteger.js index 7dba63c9a..6aecc0ab0 100644 --- a/toSafeInteger.js +++ b/toSafeInteger.js @@ -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; diff --git a/wrapperLodash.js b/wrapperLodash.js index dcd299a9c..afc37d301 100644 --- a/wrapperLodash.js +++ b/wrapperLodash.js @@ -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.