
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Is this value a JS WeakMap? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
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.
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
Similar to is-weakmap, is-map checks if a given value is a Map. While is-weakmap focuses on WeakMaps, is-map targets Maps, which are collections of key/value pairs but with keys that are not weakly referenced. Both packages serve similar purposes in type checking but for different types of collections.
Part of the Lodash library, lodash.isweakmap provides a similar functionality to is-weakmap by checking if a value is a WeakMap. Lodash is a broader utility library that offers a wide range of functions for different types of checks and operations, making lodash.isweakmap a part of a larger ecosystem. Compared to is-weakmap, which is focused solely on WeakMaps, lodash.isweakmap benefits from being part of the well-established Lodash library.
Is this value a JS WeakMap? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
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()));
Simply clone the repo, npm install
, and run npm test
v2.0.2 - 2024-03-08
0af1292
f35679b
node/install
instead of node/run
; use codecov
action cd2f0fa
6e28e6a
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, es6-shim
, object-inspect
, tape
95815ce
2c4eb0b
nyc
on all tests; use tape
runner 0a45b37
eslint
, @ljharb/eslint-config
, object-inspect
, safe-publish-latest
, tape
ffe9459
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, es5-shim
, object-inspect
, tape
c3c2f11
afa4018
eslint
, @ljharb/eslint-config
, auto-changelog
, core-js
, es5-shim
, object-inspect
, safe-publish-latest
, tape
3f22fc1
@ljharb/eslint-config
, aud
, es6-shim
, npmignore
, object-inspect
, tape
84ba754
def85cb
659031e
a916e89
01d0c7d
eslint
, @ljharb/eslint-config
, aud
, object-inspect
, tape
ad90d06
npmignore
to autogenerate an npmignore file 8b0b44f
eslint
, @ljharb/eslint-config
, es5-shim
, tape
9d8a683
core-js
tests 8ba8d2b
49769ce
eslint
, @ljharb/eslint-config
, tape
377dfac
pull_request_target
event 00f8c17
es5-shim
, tape
3a82ee8
engines.node
3671b4f
prepublishOnly
script for npm 7+ 2a5d5ea
auto-changelog
; add aud
595583b
4d6cb2c
npm test
9da2487
2f9281a
sideEffects
flag b9c8797
FAQs
Is this value a JS WeakMap? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
We found that is-weakmap 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
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.