UNPKG

dot-path-value

Version:

Safely get deep nested properties using dot notation

3 lines (2 loc) 290 B
exports.getByPath=function(t,n){return n.split(".").reduce(function(t,n){return null==t?void 0:t[n]},t)},exports.setByPath=function(t,n,r){for(var e=n.split("."),o=e.pop(),u=t,i=0;i<e.length;i++){var p=e[i];p in u||(u[p]={}),u=u[p]}return o&&(u[o]=r),t}; //# sourceMappingURL=index.cjs.map