rethinkdbdash icon indicating copy to clipboard operation
rethinkdbdash copied to clipboard

Cleaner ES6 `Proxy` implementation

Open marshall007 opened this issue 10 years ago • 0 comments

Supersedes #95 and eliminates a lot of the pitfalls I ran into with that first implementation. However, as discussed in #95, we still cannot do proxy instanceof Term directly. This is because the current implementation of Proxy in Node is not up to specification, nor is the appropriate behavior shimmed by harmony-reflect, as noted in their docs:

In full ES6 proxies, it is the intent that this trap is also triggered for proxy instanceof Function. This shim does not currently intercept that operation.

In the mean time, Term.isTerm checks for proxy._self instanceof Term which is nicer than setting a flag on the object as I was doing before. Once Proxy is fully implemented or shimmed up to spec, we can get rid of this and correctly trap the instanceof call.

TODO:

  • Check that Proxy is defined globally (i.e. available in current environment). If not, use existing behavior by modifying __proto__.

marshall007 avatar Nov 14 '15 05:11 marshall007