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

2.0.2 • Public • Published

is-weakmap Version Badge

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.2
    5,321,286
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.2
    5,321,286
  • 2.0.1
    10,216,764
  • 2.0.0
    226
  • 1.0.1
    4
  • 1.0.0
    4

Package Sidebar

Install

npm i is-weakmap

Weekly Downloads

14,143,161

Version

2.0.2

License

MIT

Unpacked Size

20.6 kB

Total Files

12

Last publish

Collaborators

  • ljharb