Gathering detailed insights and metrics for js-shortid
Gathering detailed insights and metrics for js-shortid
npm install js-shortid
Typescript
Module System
Node Version
NPM Version
68
Supply Chain
58.2
Quality
74.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
227,904
Last Day
25
Last Week
119
Last Month
833
Last Year
39,560
172 Stars
9 Commits
18 Forks
9 Watching
1 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.1
Package Id
js-shortid@0.1.1
Size
1.45 kB
NPM Version
3.6.0
Node Version
5.6.0
Cumulative downloads
Total Downloads
Last day
-16.7%
25
Compared to previous day
Last week
-40.5%
119
Compared to previous week
Last month
7.3%
833
Compared to previous month
Last year
-45.1%
39,560
Compared to previous year
Short id generator. UUID generator. Url-friendly. Non-predictable.
1npm test
If you are using bower, you can download the source like this:
1bower install js-shortid --save
js-shortid
is available in the npm repository.
1npm install js-shortid --save
node.js:
1var shortid=require('shortid'); 2console.log(shortid.gen());
browser:
1var sid = shortid.gen(); 2console.log(sid);
R6zw8Hly
R6AhD4Jw
R6Cip4M3
R6Ej09A1
R6Fjw3Q4
R6FP04jv
R6IlvZRb
R6LCSXn8
R6NT1Syx
R6O8RN67
The solution of shortid is clearly the simplest. It is constructed by the character strings:timeseq
+salts
.
The timeseq
is a time sequence since 2016-04-11(default initial time), and converted it to Base 62 string.The time sequence can be increased per millisecond, per second, per minute so on that depends on the option value interval
, default value is 1
(increase per millisecond).
The salts
is constructed by salt1+salt2+...
, each salt
is a random number and converted to Base 62 string(only two charaters).How many salts
will be append to that depends on the option values salts
,default is 2
(four charaters).More salts
of the id more closed to be a UUID, but more longer of the id.
Generally,if the timeseq
is increased per millisecond and the salts is 4
,the id is almost closed to a UUID.
Type: Integer
Default value: '2'
The value that is used to generate the salts
count.
Type: Integer
Default value: '1'
The value that is the timeseq
increased millisecond interval.1000
is increased per second,1000*60
is per minute, so on.If less than zero, there are not timeseq
.
Type: Long
Default value: '1460332800000'
The value that is the epoch of the timeseq
.The default is millisecond of 2016-04-11
.
1var inst = shortid.inst({salts:3,interval:1000}); 2console.log(inst.gen());
1//default option {salts:2,interval:1} 2console.log(shortid.gen()); 3//custom option 4console.log(shortid.gen({salts:3,interval:1000})); 5//default option {salts:4,interval:1} 6console.log(shortid.uuid());
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/8 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
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 2025-01-20
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