Last active
January 23, 2017 16:22
-
-
Save phillipskevin/39f0757c4655110d99c881ffd0ba5a92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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