Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
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 98 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 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.