@retailmenot/anchor
Version:
A React UI Library by RetailMeNot
15 lines (13 loc) • 558 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);
};
export { get as a };
//# sourceMappingURL=anchor-chunk-6ebffda8.js.map