Open caridy opened 7 years ago
@bakkot recently showed me a technique, per spec, that makes it possible to build an isProxy
function on any non-frozen object - by leveraging setPrototypeOf cycle detection. Separately, anything that already has a brand check pass on it, won't pass on the proxy for it.
That said, I agree that this should probably be a separate proposal, if for no other reason then because it will be very contentious.
Ok, I have no problem with separating it out.
by leveraging setPrototypeOf cycle detection
Yes, that is indeed a bug we need to fix. At some point we will turn https://github.com/tvcutsem/es-lab/issues/21 into a proposal. This will also make many uses of proxies much faster.
Attn @tvcutsem
One of the "features" of proxies is that they are not observables, you can't really determine if an object is profixied or not, and I believe this is something we want to preserve. I suspect @erights has more to say about this.
Additionally, I believe this proposal is about identity discontinuity, and determining if an object is a proxy or not does not qualify as so since the object should pass the identity test when compared to its proxified version.
When looking at the motivations:
I don't think that justify the feature, specially when browsers (and probably node will do the same) are providing formatters for console to represent them accordingly. E.g.: I can define a new formatter via
window.devtoolsFormatters
alongside a weakmap to show my own proxies differently in the console.My recommendation is to spin out the
Proxy.isProxy
into its own proposal that we can debate on its own.