Skip to content

Instantly share code, notes, and snippets.

View USSliberty's full-sized avatar
😎
Doing Stuff

Alessio Dal Bianco USSliberty

😎
Doing Stuff
View GitHub Profile
@USSliberty
USSliberty / class_method_proxy.js
Last active February 27, 2022 22:50
Class Method Proxy Javascript
function traceMethodCalls(obj) {
const handler = {
get(target, propKey, receiver) {
const targetValue = Reflect.get(target, propKey, receiver);
if (typeof targetValue === 'function') {
return function (...args) {
console.log('CALL', propKey, args);
return targetValue.apply(this, args); // (A)
}
} else {