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
Weekly downloads
16M
decreased by-0.17%
Maintainers
1
Install size
20.1 kB
Created
Weekly downloads
 

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.2 - 2024-03-08

Commits

  • [actions] reuse common workflows 0af1292
  • [Tests] migrate tests to Github Actions f35679b
  • [actions] use node/install instead of node/run; use codecov action cd2f0fa
  • add types 6e28e6a
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es6-shim, object-inspect, tape 95815ce
  • [readme] update URLs 2c4eb0b
  • [Tests] run nyc on all tests; use tape runner 0a45b37
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape ffe9459
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es5-shim, object-inspect, tape c3c2f11
  • [actions] remove redundant finisher afa4018
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, core-js, es5-shim, object-inspect, safe-publish-latest, tape 3f22fc1
  • [Dev Deps] update @ljharb/eslint-config, aud, es6-shim, npmignore, object-inspect, tape 84ba754
  • [actions] update rebase action to use reusable workflow def85cb
  • [actions] update codecov uploader 659031e
  • [actions] add "Allow Edits" workflow a916e89
  • [readme] remove travis badge 01d0c7d
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape ad90d06
  • [meta] use npmignore to autogenerate an npmignore file 8b0b44f
  • [Dev Deps] update eslint, @ljharb/eslint-config, es5-shim, tape 9d8a683
  • [Tests] add core-js tests 8ba8d2b
  • [readme] add actions and codecov badges 49769ce
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 377dfac
  • [actions] switch Automatic Rease workflow to pull_request_target event 00f8c17
  • [Dev Deps] update es5-shim, tape 3a82ee8
  • [meta] add missing engines.node 3671b4f
  • [meta] use prepublishOnly script for npm 7+ 2a5d5ea
  • [Dev Deps] update auto-changelog; add aud 595583b
  • [readme] remove dead badges 4d6cb2c
  • [Tests] run all tests on npm test 9da2487
  • [Tests] only audit prod deps 2f9281a
  • [meta] add sideEffects flag b9c8797

Readme

Source

is-weakmap Version Badge

github actions coverage 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 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