项目作者: inspect-js

项目描述 :
Is this value a JS WeakMap? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
高级语言: JavaScript
项目地址: git://github.com/inspect-js/is-weakmap.git
创建时间: 2019-11-11T23:03:54Z
项目社区:https://github.com/inspect-js/is-weakmap

开源协议:MIT License

下载


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

  1. var isWeakMap = require('is-weakmap');
  2. assert(!isWeakMap(function () {}));
  3. assert(!isWeakMap(null));
  4. assert(!isWeakMap(function* () { yield 42; return Infinity; });
  5. assert(!isWeakMap(Symbol('foo')));
  6. assert(!isWeakMap(1n));
  7. assert(!isWeakMap(Object(1n)));
  8. assert(!isWeakMap(new Set()));
  9. assert(!isWeakMap(new WeakSet()));
  10. assert(!isWeakMap(new Map()));
  11. assert(isWeakMap(new WeakMap()));
  12. class MyWeakMap extends WeakMap {}
  13. assert(isWeakMap(new MyWeakMap()));

Tests

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