Socket
Socket
Sign inDemoInstall

lodash.result

Package Overview
Dependencies
2
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.1 to 4.2.0

65

index.js
/**
* lodash 4.1.1 (Custom Build) <https://lodash.com/>
* lodash 4.2.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`

@@ -10,3 +10,2 @@ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>

var baseSlice = require('lodash._baseslice'),
get = require('lodash.get'),
toString = require('lodash.tostring');

@@ -36,10 +35,9 @@

/**
* The base implementation of `_.toPath` which only converts `value` to a
* path if it's not one.
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to process.
* @returns {Array} Returns the property path array.
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function baseToPath(value) {
function baseCastPath(value) {
return isArray(value) ? value : stringToPath(value);

@@ -49,2 +47,22 @@ }

/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[path[index++]];
}
return (index && index == length) ? object : undefined;
}
/**
* Checks if `value` is a property name and not a property path.

@@ -98,3 +116,3 @@ *

* @memberOf _
* @type Function
* @type {Function}
* @category Lang

@@ -172,2 +190,31 @@ * @param {*} value The value to check.

/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined` the `defaultValue` is used in its place.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned if the resolved value is `undefined`.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
/**
* This method is like `_.get` except that if the resolved value is a function

@@ -202,3 +249,3 @@ * it's invoked with the `this` binding of its parent object and its result

if (!isKey(path, object)) {
path = baseToPath(path);
path = baseCastPath(path);
var result = get(object, path);

@@ -205,0 +252,0 @@ object = parent(object, path);

3

package.json
{
"name": "lodash.result",
"version": "4.1.1",
"version": "4.2.0",
"description": "The lodash method `_.result` exported as a module.",

@@ -19,5 +19,4 @@ "homepage": "https://lodash.com/",

"lodash._baseslice": "^4.0.0",
"lodash.get": "^4.0.0",
"lodash.tostring": "^4.0.0"
}
}

@@ -1,2 +0,2 @@

# lodash.result v4.1.1
# lodash.result v4.2.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.1.1-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.2.0-npm-packages/lodash.result) for more details.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc