diff --git a/README.md b/README.md index 7082d995e..0f11ca914 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-amd v4.6.0 +# lodash-amd v4.6.1 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.6.0-amd) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.6.1-amd) for more details. diff --git a/_baseClone.js b/_baseClone.js index 6dc2bcd58..eb6cf4936 100644 --- a/_baseClone.js +++ b/_baseClone.js @@ -54,13 +54,14 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF * @private * @param {*} value The value to clone. * @param {boolean} [isDeep] Specify a deep clone. + * @param {boolean} [isFull] Specify a clone including symbols. * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. * @param {Object} [object] The parent object of `value`. * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ - function baseClone(value, isDeep, customizer, key, object, stack) { + function baseClone(value, isDeep, isFull, customizer, key, object, stack) { var result; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); @@ -90,7 +91,8 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { - return copySymbols(value, baseAssign(result, value)); + result = baseAssign(result, value); + return isFull ? copySymbols(value, result) : result; } } else { if (!cloneableTags[tag]) { @@ -109,9 +111,9 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF // Recursively populate clone (susceptible to call stack limits). (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { - assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack)); + assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - return isArr ? result : copySymbols(value, result); + return (isFull && !isArr) ? copySymbols(value, result) : result; } return baseClone; diff --git a/assign.js b/assign.js index cdb6993b6..30b69a0ac 100644 --- a/assign.js +++ b/assign.js @@ -6,8 +6,11 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; + /** Built-in value references. */ + var propertyIsEnumerable = objectProto.propertyIsEnumerable; + /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ - var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf'); + var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); /** * Assigns own enumerable properties of source objects to the destination diff --git a/assignIn.js b/assignIn.js index 9f214dc67..f948e03b6 100644 --- a/assignIn.js +++ b/assignIn.js @@ -1,7 +1,13 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', './_isPrototype', './keysIn'], function(assignValue, copyObject, createAssigner, isArrayLike, isPrototype, keysIn) { + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Built-in value references. */ + var propertyIsEnumerable = objectProto.propertyIsEnumerable; + /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ - var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf'); + var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); /** * This method is like `_.assign` except that it iterates over own and diff --git a/clone.js b/clone.js index 78657e4bf..79aa2e1a1 100644 --- a/clone.js +++ b/clone.js @@ -25,7 +25,7 @@ define(['./_baseClone'], function(baseClone) { * // => true */ function clone(value) { - return baseClone(value); + return baseClone(value, false, true); } return clone; diff --git a/cloneDeep.js b/cloneDeep.js index 5ab86714e..649b9e02f 100644 --- a/cloneDeep.js +++ b/cloneDeep.js @@ -17,7 +17,7 @@ define(['./_baseClone'], function(baseClone) { * // => false */ function cloneDeep(value) { - return baseClone(value, true); + return baseClone(value, true, true); } return cloneDeep; diff --git a/cloneDeepWith.js b/cloneDeepWith.js index 4fe4c7780..a1cf71056 100644 --- a/cloneDeepWith.js +++ b/cloneDeepWith.js @@ -27,7 +27,7 @@ define(['./_baseClone'], function(baseClone) { * // => 20 */ function cloneDeepWith(value, customizer) { - return baseClone(value, true, customizer); + return baseClone(value, true, true, customizer); } return cloneDeepWith; diff --git a/cloneWith.js b/cloneWith.js index 36af1b82a..1ebc3df4f 100644 --- a/cloneWith.js +++ b/cloneWith.js @@ -30,7 +30,7 @@ define(['./_baseClone'], function(baseClone) { * // => 0 */ function cloneWith(value, customizer) { - return baseClone(value, false, customizer); + return baseClone(value, false, true, customizer); } return cloneWith; diff --git a/main.js b/main.js index 274f691d5..3e9dea8d3 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.6.0 (Custom Build) + * lodash 4.6.1 (Custom Build) * Build: `lodash exports="amd" -d -o ./main.js` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.6.0'; + var VERSION = '4.6.1'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -1394,7 +1394,7 @@ var metaMap = WeakMap && new WeakMap; /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ - var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf'); + var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); /** Used to lookup unminified function names. */ var realNames = {}; @@ -2328,13 +2328,14 @@ * @private * @param {*} value The value to clone. * @param {boolean} [isDeep] Specify a deep clone. + * @param {boolean} [isFull] Specify a clone including symbols. * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. * @param {Object} [object] The parent object of `value`. * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ - function baseClone(value, isDeep, customizer, key, object, stack) { + function baseClone(value, isDeep, isFull, customizer, key, object, stack) { var result; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); @@ -2364,7 +2365,8 @@ } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { - return copySymbols(value, baseAssign(result, value)); + result = baseAssign(result, value); + return isFull ? copySymbols(value, result) : result; } } else { if (!cloneableTags[tag]) { @@ -2383,9 +2385,9 @@ // Recursively populate clone (susceptible to call stack limits). (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { - assignValue(result, key, baseClone(subValue, isDeep, customizer, key, value, stack)); + assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - return isArr ? result : copySymbols(value, result); + return (isFull && !isArr) ? copySymbols(value, result) : result; } /** @@ -9467,7 +9469,7 @@ * // => true */ function clone(value) { - return baseClone(value); + return baseClone(value, false, true); } /** @@ -9500,7 +9502,7 @@ * // => 0 */ function cloneWith(value, customizer) { - return baseClone(value, false, customizer); + return baseClone(value, false, true, customizer); } /** @@ -9520,7 +9522,7 @@ * // => false */ function cloneDeep(value) { - return baseClone(value, true); + return baseClone(value, true, true); } /** @@ -9550,7 +9552,7 @@ * // => 20 */ function cloneDeepWith(value, customizer) { - return baseClone(value, true, customizer); + return baseClone(value, true, true, customizer); } /** diff --git a/package.json b/package.json index c18b5485a..7f3b7ed02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-amd", - "version": "4.6.0", + "version": "4.6.1", "description": "Lodash exported as AMD modules.", "homepage": "https://lodash.com/custom-builds", "license": "MIT",