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) 966 B
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e||self).proxur=n()}(this,function(){function e(e,n){return function t(o,r,i){if(("string"==typeof r||r instanceof Array)&&r.length||((!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&console.warn("The provided path should be a string or an array, you provided "+r+" (This message won't pop up in production mode."),r=String(r)),"object"!=typeof o)return n;"string"==typeof r&&(r=r.split("."));var u=r[0];return 1===r.length?e(o,u,i):t(o[u],r.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 o(e,n){return delete e[n]}function r(e,n){return n in e}function i(e,n){return e[n]}return function(u){return void 0===u&&(u={}),new Proxy(u,{get:e(i),set:e(n,!0),has:e(r),defineProperty:e(t),deleteProperty:e(o),getPrototypeOf:function(e){return e}})}});