JSFiddle - React, Tailwind, and code Playground
by João Vitor Scheuermann
JavaScript
class X {
constructor() {
const self = this;
this.PROXY = {};
this.PROXY.CLASS = {
get: (target, property, receiver) => {
return property
},
set: (target, property, value, receiver) => {
return property
}
}
this.PROXY.CONSTRUCTOR = {
construct: (target, args, newTarget) => {
return new Proxy(new target(), this.PROXY.CLASS);
}
}
}
wrap(_name, _fn) {
return function() {
console.log('calling ' + _name);
let returnable = _fn.apply(this, arguments)
return returnable;
}
}
class(_class) {
return new Proxy(_class, this.PROXY.CONSTRUCTOR);
}
}
let x = new X;
let hue = x.class(class {
constructor() {
this.teste = 'lala'
}
})
let lolo = new hue();
console.log(lolo)