Socket
Socket
Sign inDemoInstall

is-set

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-set

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


Version published
Weekly downloads
17M
increased by2.62%
Maintainers
1
Install size
19.2 kB
Created
Weekly downloads
 

Package description

What is is-set?

The `is-set` npm package is designed to provide a simple and efficient way to check if a given value is a Set object. This can be particularly useful when working with collections of unique values and you need to ensure that the data structure being manipulated or checked is indeed a Set.

What are is-set's main functionalities?

Check if a value is a Set

This feature allows you to verify if a given value is an instance of a Set. It is particularly useful when you need to differentiate between Set objects and other iterable or collection types in JavaScript, such as Arrays, Objects, or even WeakSets. The code sample demonstrates how to use `is-set` to check various values, showing that it correctly identifies Set instances and distinguishes them from other types.

"use strict";\nconst isSet = require('is-set');\n\nconsole.log(isSet(new Set())); // true\nconsole.log(isSet(new WeakSet())); // false\nconsole.log(isSet([1, 2, 3])); // false\nconsole.log(isSet({})); // false\nconsole.log(isSet(undefined)); // false"

Other packages similar to is-set

Changelog

Source

v2.0.3 - 2024-03-08

Commits

  • [actions] reuse common workflows 9d26ac6
  • [actions] use node/install instead of node/run; use codecov action 3c91325
  • add types 8fcc646
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape 91caa24
  • [readme] update URLs 130e57b
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es5-shim, object-inspect, tape 4d75ee2
  • [actions] remove redundant finisher 052fdce
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, core-js, es5-shim, object-inspect, safe-publish-latest, tape eb31797
  • [actions] update rebase action to use reusable workflow 8c478ba
  • [actions] update codecov uploader a0dac6b
  • [Dev Deps] update @ljharb/eslint-config, aud, es6-shim, object-inspect, tape 28d75a3
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape 7b2a4a7
  • [Dev Deps] update eslint, @ljharb/eslint-config, es5-shim, tape 20ce047
  • [readme] add actions and codecov badges e6e1796
  • [meta] add missing engines.node 9ed19af
  • [meta] use prepublishOnly script for npm 7+ 618f861
  • [readme] remove dead badges 76e890e
  • [meta] add sideEffects flag e21859b

Readme

Source

is-set Version Badge

github actions coverage License Downloads

npm badge

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

Example

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

assert(!isSet(new Map()));
assert(!isSet(new WeakSet()));
assert(!isSet(new WeakMap()));

assert(isSet(new Set()));

class MySet extends Set {}
assert(isSet(new MySet()));

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