@@ -46,43 +46,46 @@ A variant of Snowflake-SI algorithm.
46
46
``` ts
47
47
import * as libuuid from " @litert/uuid" ;
48
48
49
- const makeUUID = libuuid .SnowflakeSI .createGenerateor ({
49
+ const factory = UUID .SnowflakeBI .createFactory ();
50
+
51
+ const makeUUID = factory .create ({
50
52
51
53
/**
52
54
* The machine ID.
53
55
*
54
- * By default the uinWidth is 8, and the rest 5 bits is left to MID, so
56
+ * By default the uinBitWidth is 8, and the rest 5 bits is left to MID, so
55
57
* that the mid must be between 0 and 31.
56
58
*/
57
- " mid " : 1 ,
59
+ " machineId " : 1 ,
58
60
59
61
/**
60
62
* The base-clock of generator. Is unchangeable once setup.
61
63
*
62
- * And it cannot be earlier than 2003-03-18T07:20:20Z
64
+ * And it cannot be earlier than 2003-03-18T07:20:19.225Z.
63
65
*/
64
66
" baseClock" : new Date (2004 , 0 , 1 , 0 , 0 , 0 , 0 ).getTime (),
65
-
66
67
});
67
68
68
- console .log (makeUUID ()); // Generate a UUIN
69
- console .log (makeUUID ()); // Generate a UUIN
70
- console .log (makeUUID .MS_CAPACITY ); // See the capacity of UUIDs in 1ms
71
- console .log (makeUUID .MACHINE_ID ); // See the machine ID.
72
- console .log (new Date (makeUUID .BASE_CLOCK )); // See the base-clock
69
+ console .log (makeUUID ()); // Generate a UUID
70
+ console .log (makeUUID ()); // Generate a UUID
71
+ console .log (makeUUID .uinCapacity ); // See the capacity of UUIDs in 1ms
72
+ console .log (makeUUID .machineId ); // See the machine ID.
73
+ console .log (new Date (makeUUID .baseClock )); // See the base-clock
73
74
```
74
75
75
76
### Snowflake-SI Adjustment
76
77
77
78
``` ts
78
79
import * as libuuid from " @litert/uuid" ;
79
80
80
- const makeUUID = libuuid .SnowflakeSI .createGenerateor ({
81
+ const factory = UUID .SnowflakeBI .createFactory ();
82
+
83
+ const makeUUID = factory .create ({
81
84
82
85
/**
83
86
* The machine ID.
84
87
*
85
- * Now the uinWidth has been set to 12, and only 1 bit is left to MID, so
88
+ * Now the uinBitWidth has been set to 12, and only 1 bit is left to MID, so
86
89
* that the mid can be either 1 or 0.
87
90
*/
88
91
" mid" : 1 ,
@@ -97,14 +100,14 @@ const makeUUID = libuuid.SnowflakeSI.createGenerateor({
97
100
/**
98
101
* The bit-width of UIN.
99
102
*/
100
- " uinWidth " : 12
103
+ " uinBitWidth " : 12
101
104
});
102
105
103
- console .log (makeUUID ()); // Generate a UUIN
104
- console .log (makeUUID ()); // Generate a UUIN
105
- console .log (makeUUID .MS_CAPACITY ); // See the capacity of UUIDs in 1ms
106
- console .log (makeUUID .MACHINE_ID ); // See the machine ID.
107
- console .log (new Date (makeUUID .BASE_CLOCK )); // See the base-clock
106
+ console .log (makeUUID ()); // Generate a UUID
107
+ console .log (makeUUID ()); // Generate a UUID
108
+ console .log (makeUUID .uinCapacity ); // See the capacity of UUIDs in 1ms
109
+ console .log (makeUUID .machineId ); // See the machine ID.
110
+ console .log (new Date (makeUUID .baseClock )); // See the base-clock
108
111
```
109
112
110
113
### Snowflake-SI-vA Usage
0 commit comments