Skip to content

Instantly share code, notes, and snippets.

@Anubisss
Last active April 2, 2019 09:49
Show Gist options
  • Save Anubisss/e1587f4065af64d35985b294a2bfe7f8 to your computer and use it in GitHub Desktop.
Save Anubisss/e1587f4065af64d35985b294a2bfe7f8 to your computer and use it in GitHub Desktop.
simple ES6 proxy
new Proxy(fasz, {
get(target, name) {
if (typeof target[name] === 'function') {
return function(...params) {
console.log('FUNCTION CALL', params);
return target[name](...params);
};
}
if (target[name] === undefined) {
console.log(`UNDEFINED PROPERTY/FUNCTION: ${name}`);
return;
}
console.log(`PROPERTY GET: ${name}`);
return target[name];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment