
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@remnawave/hashed-set
Advanced tools
A high-performance Set implementation with hash-based equality comparison for fast set operations.
A high-performance Set implementation that maintains a hash value for fast equality comparison. This allows for O(1) set comparison operations instead of O(n) when comparing two sets.
npm install @remnawave/hashed-set
import { HashedSet } from '@remnawave/hashed-set';
// Create a new HashedSet
const set1 = new HashedSet([1, 2, 3]);
const set2 = new HashedSet([3, 2, 1]);
// Fast comparison using hash values
console.log(set1.hash === set2.hash); // true - same elements, same hash
// Standard Set operations work as expected
set1.add(4);
set1.delete(1);
console.log(set1.has(2)); // true
console.log(set1.size); // 3
import { HashedSet } from '@remnawave/hashed-set';
const set1 = new HashedSet(['alice@example.com', 'bob@example.com']);
const set2 = new HashedSet(['bob@example.com', 'alice@example.com']);
// Quick hash comparison
if (set1.hasSameHash(set2)) {
console.log('Sets likely contain the same elements');
}
// Full equality check
if (set1.equals(set2)) {
console.log('Sets are definitely equal');
}
// Get unique hash for the set
console.log(`Set hash: ${set1.hash}`);
import { HashedSet } from '@remnawave/hashed-set';
// Create large sets
const emails1 = Array.from({ length: 100000 }, (_, i) => `user${i}@example.com`);
const emails2 = [...emails1].reverse();
const set1 = new HashedSet(emails1);
const set2 = new HashedSet(emails2);
// O(1) comparison instead of O(n)
const startTime = performance.now();
const areEqual = set1.hash === set2.hash;
const endTime = performance.now();
console.log(`Comparison took ${endTime - startTime}ms`); // ~0.01ms instead of ~100ms
new HashedSet<T>(iterable?: Iterable<T>)
- Creates a new HashedSethash: number
- Gets the current hash value of the set (unsigned 32-bit integer)size: number
- Number of elements in the set (inherited from Set)add(value: T): this
- Adds a value to the setdelete(value: T): boolean
- Removes a value from the sethas(value: T): boolean
- Checks if a value exists in the setclear(): void
- Removes all values from the setforEach()
, values()
, keys()
, entries()
- Standard iteration methodshasSameHash(other: HashedSet<T>): boolean
- Fast hash-based comparisonequals(other: Set<T>): boolean
- Deep equality comparison with hash optimizationThe library uses a combination of:
The final set hash is computed using XOR operations, making it order-independent.
AGPL-3.0-only
FAQs
A high-performance Set implementation with hash-based equality comparison for fast set operations.
The npm package @remnawave/hashed-set receives a total of 36 weekly downloads. As such, @remnawave/hashed-set popularity was classified as not popular.
We found that @remnawave/hashed-set demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.