ES6 Proxy pollyfill, with many limitations
npm install poor-mans-proxyES6 Proxy pollyfill, with many limitations
> This is a best effort polyfill, as most of Proxy's functionality can not be implemented in userland.
shell
npm install poor-mans-proxy --save
`
Usage
`js
require('poor-mans-proxy');var obj = {
name: 'Obj'
};
var proxy = new Proxy(obj, {
get: function(target, prop, receiver) {
console.log(prop, 'accessed');
return target[prop];
}
});
console.log(proxy.obj);
// : name accessed
// : Obj
`
API
####
new Proxy(target [, handler])Creates a Proxy of the target object, with handlers defined by the handler object.
_target_
Object|Function Object or Function to proxy. _handler_
Object Handler definitions.> _.get = function(target, property, receiver)_ The handler.get() method is a trap for getting a property value. See Get
> _.set = function(target, property, value, receiver)_ The handler.set() method is a trap for setting a property value. See Set
> _.apply = function(target, thisArg, argumentsList)_ The handler.apply() method is a trap for a function call (if
target is a function). See ApplyThe
target object's properties must be defined before calling new Proxy(). Dynamic properties are not supported.Test
`shell
npm install
npm test
``