Skip to content

Instantly share code, notes, and snippets.

@jonathanweiss
Created June 22, 2017 17:44
Show Gist options
  • Save jonathanweiss/73908ff845dcf426192f6e353968dc51 to your computer and use it in GitHub Desktop.
Save jonathanweiss/73908ff845dcf426192f6e353968dc51 to your computer and use it in GitHub Desktop.
Combine Proxy with new Error().stack for tracing changes.
const o = {};
const n = new Proxy(o, {
set: (obj, prop, value) => {
obj[prop + '_trace'] = new Error().stack;
obj[prop] = value;
return true;
}
});
n.a = 10;
console.log(JSON.stringify(n.a_trace, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment