diff --git a/README.md b/README.md index 188111571..fad914c1a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-es v4.16.2 +# lodash-es v4.16.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.16.2-es) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.16.3-es) for more details. diff --git a/_assignMergeValue.js b/_assignMergeValue.js index aa3992167..92d09163f 100644 --- a/_assignMergeValue.js +++ b/_assignMergeValue.js @@ -12,7 +12,7 @@ import eq from './eq.js'; */ function assignMergeValue(object, key, value) { if ((value !== undefined && !eq(object[key], value)) || - (typeof key == 'number' && value === undefined && !(key in object))) { + (value === undefined && !(key in object))) { baseAssignValue(object, key, value); } } diff --git a/_baseAssignValue.js b/_baseAssignValue.js index 540a61366..8d559965d 100644 --- a/_baseAssignValue.js +++ b/_baseAssignValue.js @@ -1,5 +1,4 @@ -/** Built-in value references. */ -var defineProperty = Object.defineProperty; +import defineProperty from './_defineProperty.js'; /** * The base implementation of `assignValue` and `assignMergeValue` without diff --git a/_baseCreate.js b/_baseCreate.js index 6a8d95548..ad1da382b 100644 --- a/_baseCreate.js +++ b/_baseCreate.js @@ -20,7 +20,7 @@ var baseCreate = (function() { if (objectCreate) { return objectCreate(proto); } - object.prototype = prototype; + object.prototype = proto; var result = new object; object.prototype = undefined; return result; diff --git a/_baseIsEqualDeep.js b/_baseIsEqualDeep.js index f0bfa37b7..70133f5cf 100644 --- a/_baseIsEqualDeep.js +++ b/_baseIsEqualDeep.js @@ -4,6 +4,7 @@ import equalByTag from './_equalByTag.js'; import equalObjects from './_equalObjects.js'; import getTag from './_getTag.js'; import isArray from './isArray.js'; +import isBuffer from './isBuffer.js'; import isTypedArray from './isTypedArray.js'; /** Used to compose bitmasks for comparison styles. */ @@ -53,6 +54,13 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { othIsObj = othTag == objectTag, isSameTag = objTag == othTag; + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } if (isSameTag && !objIsObj) { stack || (stack = new Stack); return (objIsArr || isTypedArray(object)) diff --git a/_baseMergeDeep.js b/_baseMergeDeep.js index 96433f6f0..860ea19b9 100644 --- a/_baseMergeDeep.js +++ b/_baseMergeDeep.js @@ -1,6 +1,7 @@ import assignMergeValue from './_assignMergeValue.js'; -import baseClone from './_baseClone.js'; +import cloneTypedArray from './_cloneTypedArray.js'; import copyArray from './_copyArray.js'; +import initCloneObject from './_initCloneObject.js'; import isArguments from './isArguments.js'; import isArray from './isArray.js'; import isArrayLikeObject from './isArrayLikeObject.js'; @@ -41,29 +42,32 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta var isCommon = newValue === undefined; if (isCommon) { + var isArr = isArray(srcValue), + isTyped = !isArr && isTypedArray(srcValue); + newValue = srcValue; - if (isArray(srcValue) || isTypedArray(srcValue)) { + if (isArr || isTyped) { if (isArray(objValue)) { newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } - else { + else if (isTyped) { isCommon = false; - newValue = baseClone(srcValue, true); + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; if (isArguments(objValue)) { newValue = toPlainObject(objValue); } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { - isCommon = false; - newValue = baseClone(srcValue, true); - } - else { - newValue = objValue; + newValue = initCloneObject(srcValue); } } else { diff --git a/_baseSetToString.js b/_baseSetToString.js index 1a80d1570..e712c11a0 100644 --- a/_baseSetToString.js +++ b/_baseSetToString.js @@ -1,6 +1,6 @@ import constant from './constant.js'; +import defineProperty from './_defineProperty.js'; import identity from './identity.js'; -import nativeDefineProperty from './_nativeDefineProperty.js'; /** * The base implementation of `setToString` without support for hot loop shorting. @@ -10,8 +10,8 @@ import nativeDefineProperty from './_nativeDefineProperty.js'; * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ -var baseSetToString = !nativeDefineProperty ? identity : function(func, string) { - return nativeDefineProperty(func, 'toString', { +var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { 'configurable': true, 'enumerable': false, 'value': constant(string), diff --git a/_defineProperty.js b/_defineProperty.js new file mode 100644 index 000000000..826fc1dc6 --- /dev/null +++ b/_defineProperty.js @@ -0,0 +1,11 @@ +import getNative from './_getNative.js'; + +var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +export default defineProperty; diff --git a/_nativeDefineProperty.js b/_nativeDefineProperty.js deleted file mode 100644 index 3af0910a2..000000000 --- a/_nativeDefineProperty.js +++ /dev/null @@ -1,6 +0,0 @@ -import getNative from './_getNative.js'; - -/* Built-in method references that are verified to be native. */ -var nativeDefineProperty = getNative(Object, 'defineProperty'); - -export default nativeDefineProperty; diff --git a/isFunction.js b/isFunction.js index a7ceb2b77..4f45e4d3d 100644 --- a/isFunction.js +++ b/isFunction.js @@ -2,7 +2,8 @@ import isObject from './isObject.js'; /** `Object#toString` result references. */ var funcTag = '[object Function]', - genTag = '[object GeneratorFunction]'; + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -35,7 +36,7 @@ function isFunction(value) { // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 8-9 which returns 'object' for typed array and other constructors. var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; + return tag == funcTag || tag == genTag || tag == proxyTag; } export default isFunction; diff --git a/lodash.default.js b/lodash.default.js index 2fa696005..24de68ae3 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.16.2'; +var VERSION = '4.16.3'; /** Used to compose bitmasks for function metadata. */ var BIND_KEY_FLAG = 2; diff --git a/package.json b/package.json index 878790cde..772f3179c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-es", - "version": "4.16.2", + "version": "4.16.3", "description": "Lodash exported as ES modules.", "keywords": "es6, modules, stdlib, util", "homepage": "https://lodash.com/custom-builds",