Imagine I have the following Javascript class:
class C {
constructor() {
this.foo = "bar"
}
}
I have proxied C so I can intercept construction of C:
const handler = {
construct(target, args, newTarget) {
...
}
}
I need to find a way to replace this in this.foo with a proxy. It must be done at the start of the constructor -- I cannot wait for the constructor to return and then proxy the result.
Does anyone have any suggestions on how to do this? Is it even possible?