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

2.0.3 • Public • Published

is-weakset Version Badge

github actions coverage License Downloads

npm badge

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

Example

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

assert(!isWeakSet(new Set()));
assert(!isWeakSet(new WeakMap()));
assert(!isWeakSet(new Map()));

assert(isWeakSet(new WeakSet()));

class MyWeakSet extends WeakSet {}
assert(isWeakSet(new MyWeakSet()));

Tests

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.3
    5,582,714
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.3
    5,582,714
  • 2.0.2
    9,555,423
  • 2.0.1
    216,814
  • 2.0.0
    47
  • 1.0.1
    1
  • 1.0.0
    3

Package Sidebar

Install

npm i is-weakset

Weekly Downloads

15,355,002

Version

2.0.3

License

MIT

Unpacked Size

21.2 kB

Total Files

13

Last publish

Collaborators

  • ljharb