@retailmenot/anchor
Version:
A React UI Library by RetailMeNot
17 lines (14 loc) • 571 B
JavaScript
;
/**
* @param obj - an object that needs to be safely traversed `{ a: { b: true } }`
* @param path - a string that represents the path of the object `'a.b'`
* @param defaultValue - a value to return if the path doesn't resolve in the object
* @description Our version of lodash's get() method, just less bloated.
*/
var get = function get(obj, path, defaultValue) {
return path.split('.').reduce(function (a, c) {
return a && a[c] ? a[c] : defaultValue || null;
}, obj);
};
exports.get = get;
//# sourceMappingURL=anchor-chunk-f296150d.js.map