Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2017 01:31
Show Gist options
  • Save anonymous/ed178d6513a80cce93a6deeac3ab8e54 to your computer and use it in GitHub Desktop.
Save anonymous/ed178d6513a80cce93a6deeac3ab8e54 to your computer and use it in GitHub Desktop.
const traceProperty = (object, property) => {
let value = object[property];
Object.defineProperty(object, property, {
get () {
console.trace(`${property} requested`);
return value;
},
set (newValue) {
console.trace(`setting ${property} to `, newValue);
value = newValue;
},
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment