aigoncharov / cls-proxify

Logging on steroids with CLS and Proxy. Integrated with express, koa, fastify.
MIT License
160 stars 7 forks source link

No private property forwarding #26

Open ypicard opened 2 years ago

ypicard commented 2 years ago

Hi,

Based on the current implementation, proxy method calls are not able to update the wrapped object private members. It is related to the No private property forwarding topic.

I was wondering if implementing the proposed solution in the above link would be acceptable for this project:

get(target, prop, receiver) {
    const value = target[prop];
    if (value instanceof Function) {
      return function (...args) {
        return value.apply(this === receiver ? target : this, args);
      };
    }
    return value;
}

I am not sure about side-effects and implications this could have for other use cases, but this does fix my issue.

If this is an option, I will gladly submit a PR. I will use a locally patched version of this library until then.

Thank you