
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
adaptive-set
Advanced tools
Utils for implementing a Set data structure that dynamically adjusts its internal representation based on the number of elements it contains.
A set of utils for implementing specialized Set
data structure designed to optimize memory usage and performance based on the number of elements it contains.
It adapts its internal representation to efficiently handle cases where there are no items, a single item, or multiple items.
undefined
value to represent the absence of elements, minimizing memory usage.[item]
to store the single element, providing quick access and iteration.Set
to leverage its efficient handling of multiple elements.This adaptive approach ensures that the it remains efficient and performant across different usage scenarios, making it an ideal choice for applications where the number of elements can vary significantly.
npm add adaptive-set
import { add, has, remove, size, type AdaptiveSet } from "adaptive-set";
type Fn = () => void;
class MyClass {
private listeners?: AdaptiveSet<Fn>;
public notify(): void {
if (this.listeners) {
for (const listener of this.listeners) {
listener();
}
}
}
public addListener(listener: Fn): void {
this.listeners = add(this.listeners, listener);
}
public removeListener(listener: Fn): void {
this.listeners = remove(this.listeners, listener);
}
public hasListener(listener: Fn): boolean {
return has(this.listeners, listener);
}
public getListenerCount(): number {
return size(this.listeners);
}
public clearListeners(): void {
this.listeners = undefined;
}
}
FAQs
Utils for implementing a Set data structure that dynamically adjusts its internal representation based on the number of elements it contains.
The npm package adaptive-set receives a total of 208 weekly downloads. As such, adaptive-set popularity was classified as not popular.
We found that adaptive-set demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.