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
14M
decreased by-16.38%
Maintainers
1
Install size
13.2 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

Readme

Source

is-map Version Badge

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 14 Dec 2020

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