
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.