Created
June 22, 2017 17:44
-
-
Save jonathanweiss/73908ff845dcf426192f6e353968dc51 to your computer and use it in GitHub Desktop.
Combine Proxy with new Error().stack for tracing changes.
This file contains 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
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