Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var toObject = require('./toObject');
2
3
/**
4
* The base implementation of `get` without support for string paths
5
* and default values.
6
*
7
* @private
8
* @param {Object} object The object to query.
9
* @param {Array} path The path of the property to get.
10
* @param {string} [pathKey] The key representation of path.
11
* @returns {*} Returns the resolved value.
12
*/
13
function baseGet(object, path, pathKey) {
14
if (object == null) {
15
return;
16
}
17
if (pathKey !== undefined && pathKey in toObject(object)) {
18
path = [pathKey];
19
}
20
var index = 0,
21
length = path.length;
22
23
while (object != null && index < length) {
24
object = object[path[index++]];
25
}
26
return (index && index == length) ? object : undefined;
27
}
28
29
module.exports = baseGet;
30
31