val-path-helper
Version:
val path helper
3 lines (2 loc) • 753 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertImmutabilityByPath=function(e,t){if("string"!=typeof e||!e)return{};if(!t||"[object Object]"!==Object.prototype.toString.call(t))return{};var r=e.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean),o={},n=o,i=r.length;return r.forEach((function(e,r){n[e]=r===i-1?t:{},n=n[e]})),o},exports.getPropByPath=function(e,t,r){var o;if(!e||"object"!=typeof e)return{v:r};if("string"!=typeof t||!t)return{v:r};for(var n=e,i=t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean),l=0,a=i.length;l<a-1;++l){var c=i[l];if(!(c in n))return{v:r};n=n[c]}return{o:n,k:i[l],v:null!=(o=n[i[l]])?o:r}};
//# sourceMappingURL=val-path-helper.cjs.production.min.js.map
;