English | 中文
This is a polyfill for the Proxy
constructor based on ES3 supports IE8 , Node.js, etc.
Refer to ECMAScript, and this has no external dependencies.
Due to the limitations of ES3, the polyfill supports just a limited number of proxy 'traps':
- apply
- construct
The Proxy.revocable
method is also supported, but only for calls to the above traps.
- Use NPM:
npm install -S es6-proxy-polyfill
- Download directly: Development Version, Production Version
- Browser:
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
<script type="text/javascript">
var target = function(){/* code */};
var handler = {/* code */};
var proxy = new Proxy(target, handler);
</script>
- Node.js:
require('es6-proxy-polyfill');
var target = function(){/* code */};
var handler = {/* code */};
var proxy = new Proxy(target, handler);
- In ES6, the access to
Proxy
object's properties will be passed to target. In order to simulate this feature, polyfill will try to copy properties from target by usingObject.assign
method, so it's better to load anObject.assign
polyfill first;
<script src="path/to/babel-polyfill.js" type="text/javascript"></script>
<script src="path/to/es6-proxy-polyfill.js" type="text/javascript"></script>
- The code has been tested on Node.js 0.10.48 and IE8, and it may work in other environments too;
- The revoked
Proxy
object will not throw errors when it's properties are accessed.