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
14M
decreased by-17.08%
Maintainers
1
Install size
12.8 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.2 - 2020-12-13

Commits

  • [Tests] migrate tests to Github Actions 10a1a86
  • [meta] do not publish github action workflow files 9611423
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, es6-shim, object-inspect, tape 7d4d9b3
  • [Tests] run nyc on all tests dff5fb6
  • [actions] add "Allow Edits" workflow 6bed76a
  • [readme] remove travis badge ee9e740
  • [Tests] add core-js tests 9ef1b4e
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 5661354
  • [actions] switch Automatic Rebase workflow to pull_request_target event 2cea69e
  • [Dev Deps] update es5-shim, tape 9e24b51
  • [Dev Deps] update auto-changelog; add aud 69ae556
  • Fix typo in README.md, Map -> Set 5fe826a
  • [Tests] only audit prod deps c7c67f6
  • [meta] normalize line endings 6ef4ebd

Readme

Source

is-set Version Badge

dependency status dev dependency status 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 13 Dec 2020

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