You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

is-weakset

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-weakset

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


Version published
Maintainers
1
Created

Package description

What is is-weakset?

The is-weakset npm package is a utility that allows developers to check if a given value is an instance of a WeakSet. WeakSets are collections of objects, similar to Sets, but with some key differences. Specifically, the objects in a WeakSet are held weakly, meaning if there is no other reference to an object stored in the WeakSet, it can be garbage collected. This package provides a simple and straightforward way to determine if a value is a WeakSet, which can be particularly useful when working with complex data structures or when implementing certain types of data handling logic.

What are is-weakset's main functionalities?

Check if a value is a WeakSet

This feature allows developers to check if a given value is an instance of a WeakSet. The code sample demonstrates how to use the is-weakset package to verify if a variable (ws) is a WeakSet, which returns true. It also shows that using the same function with a Set (notWs) returns false, illustrating the package's ability to distinguish between WeakSets and other types of objects.

"use strict";\nconst isWeakset = require('is-weakset');\n\nconst ws = new WeakSet();\nconst result = isWeakset(ws); // true\n\nconsole.log(result); // Outputs: true\n\nconst notWs = new Set();\nconsole.log(isWeakset(notWs)); // Outputs: false

Other packages similar to is-weakset

Changelog

Source

v2.0.3 - 2024-03-08

Commits

  • [meta] use npmignore to autogenerate an npmignore file e70d6aa
  • add types c9bbc35
  • [readme] remove dead badges fb443f6
  • [actions] remove redundant finisher eb292cc
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es5-shim, object-inspect, tape 49d0c35
  • [Dev Deps] update @ljharb/eslint-config, aud, es6-shim, npmignore, object-inspect, tape 6ec0a57
  • [actions] update rebase action to use reusable workflow d996166
  • [Deps] update call-bind, get-intrinsic e207da3
  • [meta] add missing engines.node 4d9dd14
  • [Deps] update get-intrinsic cf796dd
  • [meta] add sideEffects flag c88a25d

Readme

Source

is-weakset Version Badge

github actions coverage License Downloads

npm badge

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

Example

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

assert(!isWeakSet(new Set()));
assert(!isWeakSet(new WeakMap()));
assert(!isWeakSet(new Map()));

assert(isWeakSet(new WeakSet()));

class MyWeakSet extends WeakSet {}
assert(isWeakSet(new MyWeakSet()));

Tests

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

Keywords

FAQs

Package last updated on 08 Mar 2024

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc