angular2-data-table
Version:
angular2-data-table is a Angular2 component for presenting large and complex data.
23 lines • 652 B
JavaScript
;
/**
* Returns a deep object given a string. zoo['animal.type']
* @param {object} obj
* @param {string} path
*/
function deepValueGetter(obj, path) {
if (!obj || !path)
return obj;
var current = obj;
var split = path.split('.');
if (split.length) {
for (var i = 0, len = split.length; i < len; i++) {
current = current[split[i]];
// if found undefined, return empty string
if (current === undefined || current === null)
return '';
}
}
return current;
}
exports.deepValueGetter = deepValueGetter;
//# sourceMappingURL=deep-getter.js.map