is-map

Is this value a JS Map? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

MIT 6 个版本
安装
npm install is-map
yarn add is-map
pnpm add is-map
bun add is-map
README

is-map Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this value a JS Map? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

var isMap = require('is-map');
assert(!isMap(function () {}));
assert(!isMap(null));
assert(!isMap(function* () { yield 42; return Infinity; });
assert(!isMap(Symbol('foo')));
assert(!isMap(1n));
assert(!isMap(Object(1n)));

assert(!isMap(new Set()));
assert(!isMap(new WeakSet()));
assert(!isMap(new WeakMap()));

assert(isMap(new Map()));

class MyMap extends Map {}
assert(isMap(new MyMap()));

Tests

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

版本列表
2.0.3 2024-03-08
2.0.2 2020-12-14
2.0.1 2019-12-17
2.0.0 2019-11-12
1.0.1 2015-07-02
1.0.0 2015-02-18