poor-mans-proxy
v1.0.0
Published
ES6 Proxy pollyfill, with many limitations
Downloads
402
Readme
poor-mans-proxy
ES6 Proxy pollyfill, with many limitations
This is a best effort polyfill, as most of Proxy's functionality can not be implemented in userland.
Install
npm install poor-mans-proxy --save
Usage
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 Apply
The target
object's properties must be defined before calling new Proxy()
. Dynamic properties are not supported.
Test
npm install
npm test