tree: 98e4d7c5aff6ce1ed0fa11ac206ddadda79dc866 [path history] [tgz]
  1. .github/
  2. test/
  3. .editorconfig
  4. .eslintrc
  5. .nycrc
  6. CHANGELOG.md
  7. index.d.ts
  8. index.js
  9. LICENSE
  10. package.json
  11. README.md
  12. tsconfig.json
node_modules/is-weakmap/README.md

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