
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Is this value a JS Map? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
The `is-map` npm package is a utility library designed to provide a simple and efficient way to check if a given value is a Map object. It is particularly useful in scenarios where type-checking is necessary to ensure that operations on map-like structures are performed safely and correctly.
Type Checking for Map Objects
This feature allows developers to check if a given value is an instance of a Map. It is particularly useful for validating inputs or ensuring that certain operations are only performed on Map objects. The code sample demonstrates how to use `is-map` to distinguish between Map objects and regular JavaScript objects.
const isMap = require('is-map');
console.log(isMap(new Map())); // true
console.log(isMap({})); // false
The `is` package offers a comprehensive set of type-checking utilities, including the ability to check if a value is a Map. Compared to `is-map`, `is` provides a broader range of type checks, making it a more versatile choice for projects that require extensive type validation.
Part of the Lodash library, `lodash.ismap` offers functionality similar to `is-map` by providing a method to check if a value is classified as a Map object. While `is-map` focuses solely on Map type checking, `lodash.ismap` benefits from being part of the larger Lodash ecosystem, which includes a wide array of utility functions for different data types.
Is this value a JS Map? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
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()));
Simply clone the repo, npm install
, and run npm test
v2.0.3 - 2024-03-08
ce10d0f
npmignore
to autogenerate an npmignore file e07e23a
cd13cfb
node/install
instead of node/run
; use codecov
action 1e055f9
eslint
, @ljharb/eslint-config
, object-inspect
, safe-publish-latest
, tape
12d125e
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, es5-shim
, object-inspect
, tape
adfb18e
c5511b7
@ljharb/eslint-config
, aud
, es6-shim
, npmignore
, object-inspect
, tape
b2c7d67
bbad644
8f57f98
eslint
, @ljharb/eslint-config
, auto-changelog
, es5-shim
, object-inspect
, tape
d330ff4
eslint
, @ljharb/eslint-config
, aud
, object-inspect
, tape
454e31c
eslint
, @ljharb/eslint-config
, es5-shim
, tape
b43283d
0fc119e
eslint
, object-inspect
e2311f8
engines.node
9bddaf2
prepublishOnly
script for npm 7+ d3b7661
safe-publish-latest
00d7b69
sideEffects
flag bab4457
FAQs
Is this value a JS Map? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
The npm package is-map receives a total of 27,915,661 weekly downloads. As such, is-map popularity was classified as popular.
We found that is-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.