'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = get;
/* eslint-disable no-cond-assign */
function get(obj, prop) {
var container = obj;
var propName = prop;
var parts = prop.split('.');
var last = parts.pop();
var falseyReturn = last === 'length' ? 0 : false;
if (!container) {
return falseyReturn;
}
while (propName = parts.shift()) {
container = container[propName];
if (container == null) {
return falseyReturn;
}
}
// we don't want to return undefined
if (container[last] == null) {
return falseyReturn;
}
return container[last];
}
/* we use `get` a lot to check for objects' contents,
* mout's `get` throws an error if we give it an undefined object
* this addresses that use case */
|