
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
Unlike Typescript, type checking will be done at runtime.
An array of initial values cannot be passed during initialization.
Install with npm:
$ npm install --save typed-set
TypedSet only works with the following function signatures
f(value: any) => boolean
Notice: if the function returns a non-boolean value, the result of the check will be skipped
const TypedSet = require("typed-set");
class TestClass {}
// you can omit validation
let classicSet = new TypedSet();
// you can pass expected type as string for typeof comparison
let stringTypedSet = new TypedSet("string");
// you can pass expected class for instanceof comparison
let classTypedSet = new TypedSet(TestClass);
// you can pass function with type comparison
let anotherStringTypedSet = new TypedSet((value) => typeof value === "string");
// you can pass function with instanceof comparison
let objectTypedSet = new TypedSet((value) => value instanceof TestClass);
// you can pass function with any conditions
let typedSet = new TypedSet((value) => [1, 2, 3].includes(value));
// then use like a classic Set
typedSet.add(1);
typedSet.add(2);
typedSet.add(3);
// and catch Error when incompatible type added
try {
typedSet.add("some incompatible type");
} catch (e) {
console.log(e.message); // "Incompatible type of value"
}
List of predefined TypedSet classes for primitive types
- TypedSet.TypedBigIntSet
- TypedSet.TypedBooleanSet
- TypedSet.TypedFunctionSet
- TypedSet.TypedNumberSet
- TypedSet.TypedStringSet
- TypedSet.TypedSymbolSet
The typed-set package is open-sourced software licensed under the MIT license.
FAQs
Typed Set structure with no dependencies
We found that typed-set demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.