Oriol Bugzilla (2016-09-04T21:06:41.000Z)
> 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

  }

};

```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160904/11fa8be1/attachment-0001.html>
oriol-bugzilla at hotmail.com (2016-09-04T21:08:57.080Z)
> 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
  }
};
```