e85ff4706f620bf259bfbb2029f54ee40a1f430c4147ca6fe38ab9237cc94fe6360fed01ae6512b3f545bb98b0bafd325e10998ef8476b6c3cd607d1ebad9f 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # is-weakref <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![github actions][actions-image]][actions-url]
  3. [![coverage][codecov-image]][codecov-url]
  4. [![dependency status][deps-svg]][deps-url]
  5. [![dev dependency status][dev-deps-svg]][dev-deps-url]
  6. [![License][license-image]][license-url]
  7. [![Downloads][downloads-image]][downloads-url]
  8. [![npm badge][11]][1]
  9. Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
  10. ## Example
  11. ```js
  12. var isWeakRef = require('is-weakref');
  13. assert(!isWeakRef(function () {}));
  14. assert(!isWeakRef(null));
  15. assert(!isWeakRef(function* () { yield 42; return Infinity; });
  16. assert(!isWeakRef(Symbol('foo')));
  17. assert(!isWeakRef(1n));
  18. assert(!isWeakRef(Object(1n)));
  19. assert(!isWeakRef(new Set()));
  20. assert(!isWeakRef(new WeakSet()));
  21. assert(!isWeakRef(new Map()));
  22. assert(!isWeakRef(new WeakMap()));
  23. assert(isWeakRef(new WeakRef({})));
  24. class MyWeakRef extends WeakRef {}
  25. assert(isWeakRef(new MyWeakRef({})));
  26. ```
  27. ## Tests
  28. Simply clone the repo, `npm install`, and run `npm test`
  29. [package-url]: https://npmjs.org/package/is-weakref
  30. [npm-version-svg]: https://versionbadg.es/inspect-js/is-weakref.svg
  31. [deps-svg]: https://david-dm.org/inspect-js/is-weakref.svg
  32. [deps-url]: https://david-dm.org/inspect-js/is-weakref
  33. [dev-deps-svg]: https://david-dm.org/inspect-js/is-weakref/dev-status.svg
  34. [dev-deps-url]: https://david-dm.org/inspect-js/is-weakref#info=devDependencies
  35. [license-image]: https://img.shields.io/npm/l/is-weakref.svg
  36. [license-url]: LICENSE
  37. [downloads-image]: https://img.shields.io/npm/dm/is-weakref.svg
  38. [downloads-url]: https://npm-stat.com/charts.html?package=is-weakref
  39. [codecov-image]: https://codecov.io/gh/inspect-js/is-weakref/branch/main/graphs/badge.svg
  40. [codecov-url]: https://app.codecov.io/gh/inspect-js/is-weakref/
  41. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-weakref
  42. [actions-url]: https://github.com/inspect-js/is-weakref/actions