Socket
Socket
Sign inDemoInstall

is-weakmap

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-weakmap

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


Version published
Maintainers
1
Install size
10.7 kB
Created

Package description

What is is-weakmap?

The is-weakmap npm package is a utility that allows developers to check if a given value is a WeakMap. WeakMaps are collections of key/value pairs where the keys are weakly referenced, meaning they can be garbage collected if there is no other reference to the object. This package provides a straightforward way to determine if an object is an instance of a WeakMap, which can be useful in various programming scenarios where type checking is necessary.

What are is-weakmap's main functionalities?

Checking if a value is a WeakMap

This feature allows developers to check if a given value is an instance of WeakMap. The function returns true if the value is a WeakMap, and false otherwise. This can be particularly useful when working with data structures and ensuring that certain operations or functions are only applied to WeakMaps.

const isWeakMap = require('is-weakmap');

const wm = new WeakMap();
console.log(isWeakMap(wm)); // true

const obj = {};
console.log(isWeakMap(obj)); // false

Other packages similar to is-weakmap

Changelog

Source

v2.0.1 - 2019-12-17

Fixed

  • [Refactor] avoid top-level return, because babel and webpack are broken #79 #78 #7 #12

Commits

  • [actions] add automatic rebasing / merge commit blocking 4fa3010
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 44bafb6

Readme

Source

is-weakmap Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

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

Example

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

assert(!isWeakMap(new Set()));
assert(!isWeakMap(new WeakSet()));
assert(!isWeakMap(new Map()));

assert(isWeakMap(new WeakMap()));

class MyWeakMap extends WeakMap {}
assert(isWeakMap(new MyWeakMap()));

Tests

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

Keywords

FAQs

Last updated on 18 Dec 2019

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