blob: a194913d2172c2a7269329be49495250ee6ddcbf [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001var castPath = require('./_castPath'),
2 toKey = require('./_toKey');
3
4/**
5 * The base implementation of `_.get` without support for default values.
6 *
7 * @private
8 * @param {Object} object The object to query.
9 * @param {Array|string} path The path of the property to get.
10 * @returns {*} Returns the resolved value.
11 */
12function baseGet(object, path) {
13 path = castPath(path, object);
14
15 var index = 0,
16 length = path.length;
17
18 while (object != null && index < length) {
19 object = object[toKey(path[index++])];
20 }
21 return (index && index == length) ? object : undefined;
22}
23
24module.exports = baseGet;