File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ export function v4(): string {
1919 * rand_b:
2020 * The final 62 bits of pseudo-random data to provide uniqueness as per Section 6.2 and Section 6.6.
2121 */
22- let seq = 0 ;
2322export function v7 ( ) : string {
2423 const timeComponent = Date . now ( ) . toString ( 16 ) . padStart ( 12 , "0" ) ;
2524
@@ -33,14 +32,20 @@ export function v7(): string {
3332 "-" +
3433 timeComponent . slice ( 8 , 12 ) +
3534 "-7" +
36- ( seq ++ ) . toString ( 16 ) . padStart ( 3 , "0" ) +
35+ nextSeq ( ) . toString ( 16 ) . padStart ( 3 , "0" ) +
3736 "-" +
3837 rndArrHex . slice ( 0 , 4 ) +
3938 "-" +
4039 rndArrHex . slice ( 4 , 16 )
4140 ) ;
4241}
4342
43+ let seq = 0 ;
44+ function nextSeq ( ) {
45+ seq = seq === 0xfff ? 0 : seq + 1 ;
46+ return seq ;
47+ }
48+
4449export function fromBuffer ( buffer : Buffer ) : string {
4550 const hex = buffer . toString ( "hex" ) ;
4651 return (
You can’t perform that action at this time.
0 commit comments