proxify.js
v0.0.1-b
Published
A deep (nested) Proxy.
Readme
Proxify | a deep (nested) proxy.
Read a longer explanation on https://jochem.quora.com/ES6-function-Proxify-a-deep-nested-Proxy
So what is a deep proxy for? Normally in every day life you create an Object like this
var obj = new Object()or like that.
var obj = {}You then add a property to obj by doing this
obj.truth = 'Jochem is awesome.'but you can not do this
obj.properties.colors.primary.white = '#FFFFFF'Error: cannot read propery properties of undefined.
The following method proxify solves this problem. It implements a ‘deep proxy’ (nested proxy) that
- recursively creates and returns a new Proxy for each undefined property
- allows but does not require a handler (defaults to normal behavior)
- can be loaded as Node module using require
Install
npm install proxifyUse:
var DeepProxy = require('proxify.js')
var so = new DeepProxy()
so.you.see.that.jochem.stoel = 'awesome' // it works!Until next time.
Involuntary public figure.
