Socket
Socket
Sign inDemoInstall

is-map

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-map

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


Version published
Weekly downloads
17M
increased by1.58%
Maintainers
1
Install size
19.9 kB
Created
Weekly downloads
 

Package description

What is is-map?

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.

What are is-map's main functionalities?

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

Other packages similar to is-map

Changelog

Source

v2.0.3 - 2024-03-08

Commits

  • [actions] reuse common workflows ce10d0f
  • [meta] use npmignore to autogenerate an npmignore file e07e23a
  • add types cd13cfb
  • [actions] use node/install instead of node/run; use codecov action 1e055f9
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape 12d125e
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es5-shim, object-inspect, tape adfb18e
  • [actions] remove redundant finisher c5511b7
  • [Dev Deps] update @ljharb/eslint-config, aud, es6-shim, npmignore, object-inspect, tape b2c7d67
  • [actions] update rebase action to use reusable workflow bbad644
  • [actions] update codecov uploader 8f57f98
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, es5-shim, object-inspect, tape d330ff4
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape 454e31c
  • [Dev Deps] update eslint, @ljharb/eslint-config, es5-shim, tape b43283d
  • [readme] add actions and codecov badges 0fc119e
  • [Dev Deps] update eslint, object-inspect e2311f8
  • [meta] add missing engines.node 9bddaf2
  • [meta] use prepublishOnly script for npm 7+ d3b7661
  • [Dev Deps] update safe-publish-latest 00d7b69
  • [meta] add sideEffects flag bab4457

Readme

Source

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

Keywords

FAQs

Last updated on 08 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc