diff --git a/README.md b/README.md index 1651046b2..92c6e031b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v4.10.1 +# lodash v4.10.2 The [lodash](https://lodash.com/) library exported as [npm packages](https://www.npmjs.com/browse/keyword/lodash-modularized) per method. diff --git a/lodash.update/README.md b/lodash.update/README.md index d4725616c..987a5072c 100644 --- a/lodash.update/README.md +++ b/lodash.update/README.md @@ -1,4 +1,4 @@ -# lodash.update v4.10.1 +# lodash.update v4.10.2 The [lodash](https://lodash.com/) method `_.update` exported as a [Node.js](https://nodejs.org/) module. @@ -15,4 +15,4 @@ In Node.js: var update = require('lodash.update'); ``` -See the [documentation](https://lodash.com/docs#update) or [package source](https://github.com/lodash/lodash/blob/4.10.1-npm-packages/lodash.update) for more details. +See the [documentation](https://lodash.com/docs#update) or [package source](https://github.com/lodash/lodash/blob/4.10.2-npm-packages/lodash.update) for more details. diff --git a/lodash.update/index.js b/lodash.update/index.js index 5e97888a0..e20dee4fd 100644 --- a/lodash.update/index.js +++ b/lodash.update/index.js @@ -30,7 +30,7 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, /** * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; @@ -85,6 +85,7 @@ function isHostObject(value) { /** Used for built-in method references. */ var arrayProto = Array.prototype, + funcProto = Function.prototype, objectProto = Object.prototype; /** Used to detect overreaching core-js shims. */ @@ -97,14 +98,14 @@ var maskSrcKey = (function() { }()); /** Used to resolve the decompiled source of functions. */ -var funcToString = Function.prototype.toString; +var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -433,7 +434,7 @@ MapCache.prototype.set = mapCacheSet; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private @@ -453,7 +454,7 @@ function assignValue(object, key, value) { * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @param {Array} array The array to search. + * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ @@ -507,13 +508,16 @@ function baseIsNative(value) { * The base implementation of `_.set`. * * @private - * @param {Object} object The object to query. + * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. * @param {*} value The value to set. * @param {Function} [customizer] The function to customize path creation. * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } path = isKey(path, object) ? [path] : castPath(path); var index = -1, @@ -522,20 +526,19 @@ function baseSet(object, path, value, customizer) { nested = object; while (nested != null && ++index < length) { - var key = toKey(path[index]); - if (isObject(nested)) { - var newValue = value; - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = objValue == null - ? (isIndex(path[index + 1]) ? [] : {}) - : objValue; - } + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); } - assignValue(nested, key, newValue); } + assignValue(nested, key, newValue); nested = nested[key]; } return object; @@ -565,7 +568,7 @@ function baseToString(value) { * The base implementation of `_.update`. * * @private - * @param {Object} object The object to query. + * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to update. * @param {Function} updater The function to produce the updated value. * @param {Function} [customizer] The function to customize path creation. @@ -750,7 +753,7 @@ function toSource(func) { * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static @@ -809,7 +812,7 @@ memoize.Cache = MapCache; /** * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static @@ -887,15 +890,14 @@ var isArray = Array.isArray; */ function isFunction(value) { // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. + // 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; } /** * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static diff --git a/lodash.update/package.json b/lodash.update/package.json index 1d075f6af..d7ff94aae 100644 --- a/lodash.update/package.json +++ b/lodash.update/package.json @@ -1,6 +1,6 @@ { "name": "lodash.update", - "version": "4.10.1", + "version": "4.10.2", "description": "The lodash method `_.update` exported as a module.", "homepage": "https://lodash.com/", "icon": "https://lodash.com/icon.svg", diff --git a/lodash.updatewith/README.md b/lodash.updatewith/README.md index 4eb8524d9..ddc45cde4 100644 --- a/lodash.updatewith/README.md +++ b/lodash.updatewith/README.md @@ -1,4 +1,4 @@ -# lodash.updatewith v4.10.1 +# lodash.updatewith v4.10.2 The [lodash](https://lodash.com/) method `_.updateWith` exported as a [Node.js](https://nodejs.org/) module. @@ -15,4 +15,4 @@ In Node.js: var updateWith = require('lodash.updatewith'); ``` -See the [documentation](https://lodash.com/docs#updateWith) or [package source](https://github.com/lodash/lodash/blob/4.10.1-npm-packages/lodash.updatewith) for more details. +See the [documentation](https://lodash.com/docs#updateWith) or [package source](https://github.com/lodash/lodash/blob/4.10.2-npm-packages/lodash.updatewith) for more details. diff --git a/lodash.updatewith/index.js b/lodash.updatewith/index.js index 479b70777..beb0b8adc 100644 --- a/lodash.updatewith/index.js +++ b/lodash.updatewith/index.js @@ -30,7 +30,7 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, /** * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; @@ -85,6 +85,7 @@ function isHostObject(value) { /** Used for built-in method references. */ var arrayProto = Array.prototype, + funcProto = Function.prototype, objectProto = Object.prototype; /** Used to detect overreaching core-js shims. */ @@ -97,14 +98,14 @@ var maskSrcKey = (function() { }()); /** Used to resolve the decompiled source of functions. */ -var funcToString = Function.prototype.toString; +var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -433,7 +434,7 @@ MapCache.prototype.set = mapCacheSet; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private @@ -453,7 +454,7 @@ function assignValue(object, key, value) { * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @param {Array} array The array to search. + * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ @@ -507,13 +508,16 @@ function baseIsNative(value) { * The base implementation of `_.set`. * * @private - * @param {Object} object The object to query. + * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. * @param {*} value The value to set. * @param {Function} [customizer] The function to customize path creation. * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } path = isKey(path, object) ? [path] : castPath(path); var index = -1, @@ -522,20 +526,19 @@ function baseSet(object, path, value, customizer) { nested = object; while (nested != null && ++index < length) { - var key = toKey(path[index]); - if (isObject(nested)) { - var newValue = value; - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = objValue == null - ? (isIndex(path[index + 1]) ? [] : {}) - : objValue; - } + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); } - assignValue(nested, key, newValue); } + assignValue(nested, key, newValue); nested = nested[key]; } return object; @@ -565,7 +568,7 @@ function baseToString(value) { * The base implementation of `_.update`. * * @private - * @param {Object} object The object to query. + * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to update. * @param {Function} updater The function to produce the updated value. * @param {Function} [customizer] The function to customize path creation. @@ -750,7 +753,7 @@ function toSource(func) { * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static @@ -809,7 +812,7 @@ memoize.Cache = MapCache; /** * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static @@ -887,15 +890,14 @@ var isArray = Array.isArray; */ function isFunction(value) { // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. + // 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; } /** * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static diff --git a/lodash.updatewith/package.json b/lodash.updatewith/package.json index 711439715..829b07f74 100644 --- a/lodash.updatewith/package.json +++ b/lodash.updatewith/package.json @@ -1,6 +1,6 @@ { "name": "lodash.updatewith", - "version": "4.10.1", + "version": "4.10.2", "description": "The lodash method `_.updateWith` exported as a module.", "homepage": "https://lodash.com/", "icon": "https://lodash.com/icon.svg",