lodash.result
Advanced tools
Comparing version 2.4.1 to 3.0.0
58
index.js
/** | ||
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/> | ||
* Build: `lodash modularize modern exports="npm" -o ./npm/` | ||
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <http://lodash.com/license> | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
@@ -12,35 +12,39 @@ var isFunction = require('lodash.isfunction'); | ||
/** | ||
* Resolves the value of property `key` on `object`. If `key` is a function | ||
* it will be invoked with the `this` binding of `object` and its result returned, | ||
* else the property value is returned. If `object` is falsey then `undefined` | ||
* is returned. | ||
* Resolves the value of property `key` on `object`. If the value of `key` is | ||
* a function it is invoked with the `this` binding of `object` and its result | ||
* is returned, else the property value is returned. If the property value is | ||
* `undefined` the `defaultValue` is used in its place. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Utilities | ||
* @param {Object} object The object to inspect. | ||
* @param {string} key The name of the property to resolve. | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @param {string} key The key of the property to resolve. | ||
* @param {*} [defaultValue] The value returned if the property value | ||
* resolves to `undefined`. | ||
* @returns {*} Returns the resolved value. | ||
* @example | ||
* | ||
* var object = { | ||
* 'cheese': 'crumpets', | ||
* 'stuff': function() { | ||
* return 'nonsense'; | ||
* } | ||
* }; | ||
* var object = { 'user': 'fred', 'age': _.constant(40) }; | ||
* | ||
* _.result(object, 'cheese'); | ||
* // => 'crumpets' | ||
* _.result(object, 'user'); | ||
* // => 'fred' | ||
* | ||
* _.result(object, 'stuff'); | ||
* // => 'nonsense' | ||
* _.result(object, 'age'); | ||
* // => 40 | ||
* | ||
* _.result(object, 'status', 'busy'); | ||
* // => 'busy' | ||
* | ||
* _.result(object, 'status', _.constant('busy')); | ||
* // => 'busy' | ||
*/ | ||
function result(object, key) { | ||
if (object) { | ||
var value = object[key]; | ||
return isFunction(value) ? object[key]() : value; | ||
function result(object, key, defaultValue) { | ||
var value = object == null ? undefined : object[key]; | ||
if (typeof value == 'undefined') { | ||
value = defaultValue; | ||
} | ||
return isFunction(value) ? value.call(object) : value; | ||
} | ||
module.exports = result; |
@@ -1,3 +0,3 @@ | ||
Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas, | ||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -22,2 +22,2 @@ | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
{ | ||
"name": "lodash.result", | ||
"version": "2.4.1", | ||
"description": "The Lo-Dash function `_.result` as a Node.js module generated by lodash-cli.", | ||
"homepage": "http://lodash.com/custom-builds", | ||
"version": "3.0.0", | ||
"description": "The modern build of lodash’s `_.result` as a module.", | ||
"homepage": "https://lodash.com/", | ||
"icon": "https://lodash.com/icon.svg", | ||
"license": "MIT", | ||
"keywords": ["functional", "lodash", "lodash-modularized", "server", "util"], | ||
"keywords": "lodash, lodash-modularized, stdlib, util", | ||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"contributors": [ | ||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | ||
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | ||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | ||
"Mathias Bynens <mathias@qiwi.be> (http://mathiasbynens.be/)" | ||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" | ||
], | ||
"bugs": "https://github.com/lodash/lodash-cli/issues", | ||
"repository": { "type": "git", "url": "https://github.com/lodash/lodash-cli.git" }, | ||
"repository": "lodash/lodash", | ||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }, | ||
"dependencies": { | ||
"lodash.isfunction": "~2.4.1" | ||
"lodash.isfunction": "^3.0.0" | ||
} | ||
} |
@@ -1,15 +0,20 @@ | ||
# lodash.result v2.4.1 | ||
# lodash.result v3.0.0 | ||
The [Lo-Dash](http://lodash.com/) function [`_.result`](http://lodash.com/docs#result) as a [Node.js](http://nodejs.org/) module generated by [lodash-cli](https://npmjs.org/package/lodash-cli). | ||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.result` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
## Author | ||
## Installation | ||
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") | | ||
|---| | ||
| [John-David Dalton](http://allyoucanleet.com/) | | ||
Using npm: | ||
## Contributors | ||
```bash | ||
$ {sudo -H} npm i -g npm | ||
$ npm i --save lodash.result | ||
``` | ||
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](https://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | | ||
|---|---|---| | ||
| [Blaine Bublitz](http://www.iceddev.com/) | [Kit Cambridge](http://kitcambridge.be/) | [Mathias Bynens](http://mathiasbynens.be/) | | ||
In Node.js/io.js: | ||
```js | ||
var result = require('lodash.result'); | ||
``` | ||
See the [documentation](https://lodash.com/docs#result) or [package source](https://github.com/lodash/lodash/blob/3.0.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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
47
21
4348
1
+ Addedlodash.isfunction@3.0.9(transitive)
- Removedlodash.isfunction@2.4.1(transitive)
Updatedlodash.isfunction@^3.0.0