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