1.0.0 • Published 10 years ago

poor-mans-proxy v1.0.0

Weekly downloads
529
License
MIT
Repository
github
Last release
10 years ago

poor-mans-proxy Build Status npm version

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
1.0.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago