Gathering detailed insights and metrics for hyperid
Gathering detailed insights and metrics for hyperid
Gathering detailed insights and metrics for hyperid
Gathering detailed insights and metrics for hyperid
hyperdyperid
Fastest random ID and random string generation for Node.js
happner-hyperid
## fast unique id generation, compatible with node 0.10-8
@12core/hyperid-wasm
hyperid implementation written in ZZ compiled to WASM format
@little-core-labs/hyperid-wasm
hyperid implementation written in ZZ compiled to WASM format
Uber-fast unique id generation, for Node.js and the browser
npm install hyperid
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
727 Stars
101 Commits
38 Forks
9 Watching
1 Branches
21 Contributors
Updated on 11 Nov 2024
JavaScript (94.89%)
TypeScript (5.11%)
Cumulative downloads
Total Downloads
Last day
-7.1%
116,826
Compared to previous day
Last week
-4.5%
663,185
Compared to previous week
Last month
55.7%
2,453,986
Compared to previous month
Last year
97.9%
19,568,274
Compared to previous year
Uber-fast unique id generation, for Node.js and the browser. Here are the benchmarks:
crypto.randomUUID x 12,969,725 ops/sec ±0.88% (91 runs sampled)
hashids process.hrtime x 419,350 ops/sec ±0.66% (94 runs sampled)
hashids counter x 819,049 ops/sec ±0.58% (93 runs sampled)
shortid x 40,820 ops/sec ±2.49% (87 runs sampled)
crypto.random x 372,773 ops/sec ±2.39% (84 runs sampled)
nid x 1,614,450 ops/sec ±0.38% (93 runs sampled)
uuid.v4 x 1,446,051 ops/sec ±0.60% (98 runs sampled)
napiRsUuid.v4 x 8,676,151 ops/sec ±0.49% (97 runs sampled)
uuid.v1 x 2,051,072 ops/sec ±0.15% (99 runs sampled)
nanoid x 4,293,733 ops/sec ±0.31% (97 runs sampled)
hyperid - variable length x 25,937,129 ops/sec ±1.48% (91 runs sampled)
hyperid - fixed length x 24,970,478 ops/sec ±1.48% (92 runs sampled)
hyperid - fixed length, url safe x 25,856,735 ops/sec ±1.93% (92 runs sampled)
Fastest is hyperid - variable length,hyperid - fixed length, url safe
Slowest is shortid
Note: Benchmark run with Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz and Node.js v22.0.0
As you can see the native crypto.randomUUID
is almost as fast as hyperid
on Node.js v16, but not on v14.
npm i hyperid --save
1'use strict' 2 3const hyperid = require('hyperid') 4const instance = hyperid() 5 6const id = instance() 7 8console.log(id) 9console.log(instance()) 10console.log(hyperid.decode(id)) 11console.log(hyperid.decode(instance()))
Returns a function to generate unique ids. The function can accept one of the following parameters:
fixedLength: Boolean
If fixedLength is true
the function will always generate an id
that is 33 characters in length, by default fixedLength
is false
.options: Object
If { fixedLength: true }
is passed in, the function will always generate an id
that is 33 characters in length, by default fixedLength
is false
.
If { urlSafe: true }
is passed in, the function will generate url safe ids according to RFC4648.
If { startFrom: <int> }
is passed in, the first counter will start from that
number, which must be between 0 and 2147483647. Fractions are discarded, only the
integer part matters.
If { maxInt: <int> }
is passed in, the uuid will be re-generated once the maxInt is reached. The lesser the maxInt, higher the performance because of SMI (a V8 optimization).Returns an unique id.
The uuid used to generate the ids, it will change over time.
If maxInt
is provided in options, then it will regenerated every maxInt
, else it will be regenerated every Math.pow(2, 31) - 1
to keep the integer a SMI (a V8 optimization).
Decode the unique id into its two components, a uuid
and a counter.
If you are generating url safe ids, you must pass { urlSafe: true }
as option.
It returns:
1{ 2 uuid: '049b7020-c787-41bf-a1d2-a97612c11418', 3 count: 1 4}
This is aliased as instance.decode
.
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 10/30 approved changesets -- score normalized to 3
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More