cls-proxify icon indicating copy to clipboard operation
cls-proxify copied to clipboard

No private property forwarding

Open ypicard opened this issue 2 years ago • 0 comments

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

ypicard avatar Oct 11 '22 19:10 ypicard