Skip to content

Instantly share code, notes, and snippets.

@victor141516
Created October 11, 2022 11:28
Show Gist options
  • Save victor141516/7234b2597df7ef0daca1c4ed9a2431f0 to your computer and use it in GitHub Desktop.
Save victor141516/7234b2597df7ef0daca1c4ed9a2431f0 to your computer and use it in GitHub Desktop.
Recursive proxy for debugging purposes
(() => {
const a = (prefix = '') =>
new Proxy(
{},
{
get(_, p) {
const newPrefix = [prefix.toString(), p.toString()].join('.');
console.log('get: ', newPrefix);
return a(newPrefix);
},
set(_, p, newValue) {
const newPrefix = [prefix.toString(), p.toString()].join('.');
console.log('set:', newPrefix, newValue);
return true;
},
},
);
return a();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment