UNPKG

proxur

Version:

Zero config, zero dependency, safe and lightweight (427 bytes gzipped!) proxy supporting both dot syntax and regular syntax.

2 lines (1 loc) 799 B
function e(e,n){return function t(r,o,i){if(("string"==typeof o||o instanceof Array)&&o.length||((!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&console.warn("The provided path should be a string or an array, you provided "+o+" (This message won't pop up in production mode."),o=String(o)),"object"!=typeof r)return n;"string"==typeof o&&(o=o.split("."));var u=o[0];return 1===o.length?e(r,u,i):t(r[u],o.slice(1),i)}}function n(e,n,t){return e[n]=t,!0}var t=function(e,n,t){return Object.defineProperty(e,n,t),!0};function r(e,n){return delete e[n]}function o(e,n){return n in e}function i(e,n){return e[n]}module.exports=function(u){return void 0===u&&(u={}),new Proxy(u,{get:e(i),set:e(n,!0),has:e(o),defineProperty:e(t),deleteProperty:e(r),getPrototypeOf:function(e){return e}})};