Skip to content

Instantly share code, notes, and snippets.

@phillipskevin
Last active January 23, 2017 16:22
Show Gist options
  • Save phillipskevin/39f0757c4655110d99c881ffd0ba5a92 to your computer and use it in GitHub Desktop.
Save phillipskevin/39f0757c4655110d99c881ffd0ba5a92 to your computer and use it in GitHub Desktop.
return new Proxy(this, {
get: function(target, prop) {
var funcOrProp = target[prop];
if (typeof funcOrProp === 'function') {
return function() {
var result = funcOrProp.apply(target, arguments);
console.log(prop + '(' + [].join.call(arguments, ',') + ') -> ' + JSON.stringify(result));
return result;
}
} else {
console.log('GET', prop, '->', funcOrProp);
return funcOrProp;
}
},
set: function(target, prop, value) {
console.log('SET', prop, 'to', value);
target[prop] = value;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment