is-weakmap <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

Is this value a JS WeakMap? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

var isWeakMap = require('is-weakmap');
assert(!isWeakMap(function () {}));
assert(!isWeakMap(null));
assert(!isWeakMap(function* () { yield 42; return Infinity; });
assert(!isWeakMap(Symbol('foo')));
assert(!isWeakMap(1n));
assert(!isWeakMap(Object(1n)));

assert(!isWeakMap(new Set()));
assert(!isWeakMap(new WeakSet()));
assert(!isWeakMap(new Map()));

assert(isWeakMap(new WeakMap()));

class MyWeakMap extends WeakMap {}
assert(isWeakMap(new MyWeakMap()));

Tests

Simply clone the repo, npm install, and run npm test

is-weakmap - Installation

To install is-weakmap via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install is-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install is-weakmap

Learn more about the config option.

PNPM

pnpm install is-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install is-weakmap --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

is-weakmap - Download

Download Tarball (v2.0.2)

Integrity sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==
SHASUM bf72615d649dfe5f699079c54b83e47d1ae19cfd
Tarball https://js.registry.sudovanilla.org/is-weakmap/-/is-weakmap-2.0.2.tgz