forked from GoogleChrome/proxy-polyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.min.js
4 lines (4 loc) · 1.61 KB
/
proxy.min.js
1
2
3
4
(function(c){function l(a){return a?"object"===typeof a||"function"===typeof a:!1}if(!c.Proxy){var m=null;c.a=function(a,b){function c(){}if(!l(a)||!l(b))throw new TypeError("Cannot create proxy with a non-object as target or handler");m=function(){c=function(a){throw new TypeError("Cannot perform '"+a+"' on a proxy that has been revoked");}};var e=b;b={get:null,set:null,apply:null,construct:null};for(var h in e){if(!(h in b))throw new TypeError("Proxy polyfill does not support trap '"+h+"'");b[h]=
e[h]}"function"===typeof e&&(b.apply=e.apply.bind(e));var d=this,n=!1;"function"===typeof a&&(d=function(){var g=this&&this.constructor===d,f=Array.prototype.slice.call(arguments);c(g?"construct":"apply");return g&&b.construct?b.construct.call(this,a,f):!g&&b.apply?b.apply(a,this,f):g?(f.unshift(a),new (a.bind.apply(a,f))):a.apply(this,f)},n=!0);var p=b.get?function(a){c("get");return b.get(this,a,d)}:function(a){c("get");return this[a]},r=b.set?function(a,f){c("set");b.set(this,a,f,d)}:function(a,
b){c("set");this[a]=b},q={};Object.getOwnPropertyNames(a).forEach(function(b){n&&b in d||(Object.defineProperty(d,b,{enumerable:!!Object.getOwnPropertyDescriptor(a,b).enumerable,get:p.bind(a,b),set:r.bind(a,b)}),q[b]=!0)});e=!0;Object.setPrototypeOf?Object.setPrototypeOf(d,Object.getPrototypeOf(a)):d.__proto__?d.__proto__=a.__proto__:e=!1;if(b.get||!e)for(var k in a)q[k]||Object.defineProperty(d,k,{get:p.bind(a,k)});Object.seal(a);Object.seal(d);return d};c.a.b=function(a,b){return{proxy:new c.a(a,
b),revoke:m}};c.a.revocable=c.a.b;c.Proxy=c.a}})("undefined"!==typeof process&&"[object process]"==={}.toString.call(process)?global:self);