lodash.result
Advanced tools
Comparing version 4.3.0 to 4.4.0
45
index.js
/** | ||
* lodash 4.3.0 (Custom Build) <https://lodash.com/> | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
@@ -11,2 +11,5 @@ * Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
@@ -25,3 +28,4 @@ var funcTag = '[object Function]', | ||
/** | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -38,3 +42,3 @@ */ | ||
*/ | ||
function baseCastPath(value) { | ||
function castPath(value) { | ||
return isArray(value) ? value : stringToPath(value); | ||
@@ -52,12 +56,30 @@ } | ||
function isKey(value, object) { | ||
if (isArray(value)) { | ||
return false; | ||
} | ||
var type = typeof value; | ||
if (type == 'number' || type == 'symbol') { | ||
if (type == 'number' || type == 'symbol' || type == 'boolean' || | ||
value == null || isSymbol(value)) { | ||
return true; | ||
} | ||
return !isArray(value) && | ||
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | ||
(object != null && value in Object(object))); | ||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | ||
(object != null && value in Object(object)); | ||
} | ||
/** | ||
* Converts `value` to a string key if it's not a string or symbol. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @returns {string|symbol} Returns the key. | ||
*/ | ||
function toKey(value) { | ||
if (typeof value == 'string' || isSymbol(value)) { | ||
return value; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
@@ -116,4 +138,5 @@ * | ||
/** | ||
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. | ||
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* Checks if `value` is the | ||
* [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) | ||
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) | ||
* | ||
@@ -226,3 +249,3 @@ * @static | ||
function result(object, path, defaultValue) { | ||
path = isKey(path, object) ? [path] : baseCastPath(path); | ||
path = isKey(path, object) ? [path] : castPath(path); | ||
@@ -238,3 +261,3 @@ var index = -1, | ||
while (++index < length) { | ||
var value = object == null ? undefined : object[path[index]]; | ||
var value = object == null ? undefined : object[toKey(path[index])]; | ||
if (value === undefined) { | ||
@@ -241,0 +264,0 @@ index = length; |
{ | ||
"name": "lodash.result", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"description": "The lodash method `_.result` exported as a module.", | ||
@@ -18,4 +18,4 @@ "homepage": "https://lodash.com/", | ||
"dependencies": { | ||
"lodash._stringtopath": "~4.7.0" | ||
"lodash._stringtopath": "~4.8.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.result v4.3.0 | ||
# lodash.result v4.4.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.result` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#result) or [package source](https://github.com/lodash/lodash/blob/4.3.0-npm-packages/lodash.result) for more details. | ||
See the [documentation](https://lodash.com/docs#result) or [package source](https://github.com/lodash/lodash/blob/4.4.0-npm-packages/lodash.result) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9949
248
+ Addedlodash._basetostring@4.12.0(transitive)
+ Addedlodash._stringtopath@4.8.0(transitive)
- Removedlodash._stringtopath@4.7.1(transitive)
Updatedlodash._stringtopath@~4.8.0