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