
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
hash-states
Advanced tools
High-performance collection of states for easy generation of hash strings.
Usage:
import { HashStates } from 'hash-states';
const states = new HashStates();
states
.clear()
.setString("name", "Shawn")
.setNumber("age", 30)
.setBoolean("human", true)
.setBoolean("male", true)
.setBoolean("awesome", true)
.setBoolean("sad", false);
console.log(states.getHash()); // Shawn|30|7
console.log(states.getString("name")); // Shawn
console.log(states.getBoolean("awesome")); // true
For space efficiency, all boolean values are stored in binary form. Therefore, the aforementioned example would be stored as 111, which is equivalent to 7 in decimal notation. So if numerous Boolean values are set, HashStates will significantly shorten the length of the resulting hash string.
here is the benchmark result of HashStates compared to Object:
set values:
states x 57,623 ops/sec ±3.01% (74 runs sampled)
_array x 13,929 ops/sec ±0.24% (95 runs sampled)
object x 72,747 ops/sec ±0.41% (93 runs sampled)
Fastest is object
get hash:
states x 147,151 ops/sec ±0.23% (97 runs sampled)
_array x 184,957 ops/sec ±0.18% (95 runs sampled)
object x 45,221 ops/sec ±0.16% (96 runs sampled)
Fastest is _array
hash1Count 1114
hash2Count 1629
get values:
states x 1,101,099 ops/sec ±0.68% (90 runs sampled)
_array x 63,943 ops/sec ±0.42% (93 runs sampled)
object x 359,494 ops/sec ±0.19% (95 runs sampled)
Fastest is states
all:
states x 42,122 ops/sec ±0.96% (88 runs sampled)
_array x 24,750 ops/sec ±0.19% (95 runs sampled)
object x 23,366 ops/sec ±0.30% (95 runs sampled)
Fastest is states
While HashStates is marginally slower in setting values, it exhibits significant performance advantages in getHash and getValue operations. Overall, its performance is nearly twice as efficient as a standard Object.
FAQs
High-performance collection of states for easy generation of hash strings.
We found that hash-states 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's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.

Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.

Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.