mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
34 lines
882 B
JavaScript
34 lines
882 B
JavaScript
|
import baseGet from './_baseGet.js';
|
||
|
|
||
|
/**
|
||
|
* Gets the value at `path` of `object`. If the resolved value is
|
||
|
* `undefined`, the `defaultValue` is returned in its place.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @since 3.7.0
|
||
|
* @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 for `undefined` resolved values.
|
||
|
* @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;
|
||
|
}
|
||
|
|
||
|
export default get;
|