Skip to content

Instantly share code, notes, and snippets.

@calebdwilliams
Forked from anonymous/traceProperty.js
Created July 3, 2017 17:29
Show Gist options
  • Save calebdwilliams/425ddbcaa74aa2769020795e464579cf to your computer and use it in GitHub Desktop.
Save calebdwilliams/425ddbcaa74aa2769020795e464579cf 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;
},
})
};
@calebdwilliams
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment