@newdash/newdash
Version:
javascript/typescript utility library
26 lines (25 loc) • 915 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const castPath_1 = __importDefault(require("./castPath"));
const toKey_1 = __importDefault(require("./toKey"));
/**
* 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 = (0, castPath_1.default)(path, object);
let index = 0;
const length = path.length;
while (object != null && index < length) {
object = object[(0, toKey_1.default)(path[index++])];
}
return (index && index == length) ? object : undefined;
}
exports.default = baseGet;