is-proxy
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

is-proxy

dependency status License Downloads

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

GitHub Profile

MIT Licensed

Package Sidebar

Install

npm i is-proxy

Weekly Downloads

55

Version

1.0.6

License

MIT

Unpacked Size

10.6 kB

Total Files

7

Last publish

Collaborators

  • null96