Skip to content

Instantly share code, notes, and snippets.

@lukeburns
Last active December 25, 2015 09:29
Show Gist options
  • Select an option

  • Save lukeburns/6954291 to your computer and use it in GitHub Desktop.

Select an option

Save lukeburns/6954291 to your computer and use it in GitHub Desktop.
Deep proxy setter for the universe
require('harmony-reflect');
var universe = Proxy({}, {
set: function(obj, keypath, val) {
var keys = keypath.split('.');
while(keys.length !== 1) {
obj = obj[keys[0]] = obj[keys[0]] || {};
keys.shift();
}
obj[keys[0]] = val;
}
});
universe['milky.solar'] = ['earth', 'mars'];
console.log(universe.milky.solar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment