Socket
Socket
Sign inDemoInstall

is-weakset

Package Overview
Dependencies
12
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
Install size
111 kB
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.2 - 2021-12-12

Commits

  • [actions] reuse common workflows a8f7c7f
  • [Tests] migrate tests to Github Actions f38af72
  • [Refactor] use call-bind and get-intrinsic to be more robust 5102e7e
  • [meta] do not publish github action workflow files 6ac6e8e
  • [actions] use node/install instead of node/run; use codecov action 304af52
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es6-shim, object-inspect, tape b82fb5f
  • [Tests] run nyc on all tests; use tape runner 89e2611
  • [Dev Deps] update eslint, @ljharb/eslint-config, es5-shim, object-inspect, safe-publish-latest, tape 42b0bdc
  • [actions] update codecov uploader 112697a
  • [actions] add "Allow Edits" workflow 1af6ffe
  • [readme] remove travis badge dff769b
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape 4494ced
  • [Dev Deps] update eslint, @ljharb/eslint-config, es5-shim, tape a2c11c6
  • [Tests] add core-js tests cd619e9
  • [readme] add actions and codecov badges d3cbefe
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 3d54035
  • [Dev Deps] update auto-changelog, eslint a80fb4a
  • [actions] switch Automatic Rease workflow to pull_request_target event b3b8aee
  • [Dev Deps] update es5-shim, tape 5ba5ca8
  • [meta] use prepublishOnly script for npm 7+ b4f7636
  • [Dev Deps] update auto-changelog; add aud 2ccd594
  • [Fix] when WeakSet lacks a has, return false 53a2cbc
  • [Tests] only audit prod deps f74aaf5
  • [meta] normalize line endings 31f60a6

Readme

Source

is-weakset Version Badge

github actions coverage dependency status dev dependency status 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

Last updated on 13 Dec 2021

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