UNPKG

dot-path-value

Version:

Safely get deep nested properties using dot notation

3 lines (2 loc) 469 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).dotPathValue={})}(this,function(e){e.getByPath=function(e,t){return t.split(".").reduce(function(e,t){return null==e?void 0:e[t]},e)},e.setByPath=function(e,t,n){for(var o=t.split("."),i=o.pop(),f=e,u=0;u<o.length;u++){var r=o[u];r in f||(f[r]={}),f=f[r]}return i&&(f[i]=n),e}}); //# sourceMappingURL=index.umd.js.map