
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
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.
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"
While `lodash.isset` does not exist as a standalone package, Lodash as a utility library offers functions like `_.isSet` which provide similar functionality to `is-set`. Lodash's `_.isSet` function checks if a value is classified as a Set object. The main difference is that Lodash offers a wide range of utility functions beyond checking for Sets, making it a more comprehensive solution for different types of data manipulations and checks.
The `is` package offers a wide range of type-check functions, including checks for Sets. Similar to `is-set`, it can be used to determine if a given value is a Set. However, `is` goes beyond just Sets, offering type checks for a variety of JavaScript data types and structures, making it a more versatile package if you need to perform multiple types of checks.
Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
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()));
Simply clone the repo, npm install
, and run npm test
v2.0.3 - 2024-03-08
9d26ac6
node/install
instead of node/run
; use codecov
action 3c91325
8fcc646
eslint
, @ljharb/eslint-config
, object-inspect
, safe-publish-latest
, tape
91caa24
130e57b
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, es5-shim
, object-inspect
, tape
4d75ee2
052fdce
eslint
, @ljharb/eslint-config
, auto-changelog
, core-js
, es5-shim
, object-inspect
, safe-publish-latest
, tape
eb31797
8c478ba
a0dac6b
@ljharb/eslint-config
, aud
, es6-shim
, object-inspect
, tape
28d75a3
eslint
, @ljharb/eslint-config
, aud
, object-inspect
, tape
7b2a4a7
eslint
, @ljharb/eslint-config
, es5-shim
, tape
20ce047
e6e1796
engines.node
9ed19af
prepublishOnly
script for npm 7+ 618f861
76e890e
sideEffects
flag e21859b
FAQs
Is this value a JS Set? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
The npm package is-set receives a total of 15,654,421 weekly downloads. As such, is-set popularity was classified as popular.
We found that is-set demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.