> Could there be a Proxy.hasBeenRevoked(proxy) method?

The Proxy constructor only accepts targets and handlers when they are objects 
and are not revoked proxies.

I wonder what's the point of not allowing revoked proxies but allow revocable 
proxies which may be revoked later.


Anyways, this allows you to check if a value is a revoked proxy: you only need 
to ensure that it's an object but makes Proxy throw.

I think something like this should work:


```javascript

Proxy.hasBeenRevoked = function(value) {

  if(Object(value) !== value) {

    return false; // Primitive value

  }

  try {

    new Proxy(value, value);

    return false; // Either non-proxy object or non-revoked proxy

  } catch(err) {

    return true; // Revoked proxy

  }

};

```
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to