1.0.6 • Published 2 years ago
is-proxy v1.0.6
is-proxy
Checks whether a value is a proxy object
Install
Install using npm:
npm install --save is-proxy
or using yarn
yarn add is-proxy
Usage
In order for this library to track when a Proxy object is created, it has to either mutate global Proxy constructor or enforce usage of its own Proxy constructor.
Assigning Proxy to the global object
Note: In this case you must include this library at the top of your entry point, so it can pick up Proxy creation properly.
// At the top of your entry point
import 'is-proxy';
// Later
import { isProxy } from 'is-proxy';
const myProxy = new Proxy({}, {});
const myRevocableProxy = Proxy.revocable({}, {});
isProxy(myProxy); // ~> true
isProxy(myRevocableProxy.proxy); // ~> true
Without global namespace pollution
import { isProxy, Proxy } from 'is-proxy/pure';
const myProxy = new Proxy({}, {});
const myRevocableProxy = Proxy.revocable({}, {});
isProxy(myProxy); // ~> true
isProxy(myRevocableProxy.proxy); // ~> true
API
Available in is-proxy
and is-proxy/pure
:
isProxy(o: any): boolean - returns true if o
is a proxy object, false if it is not.
Available in is-proxy/pure
:
Proxy - JavaScript Proxy
, with proxy creation tracking.
Author
Max Kanaradze