@@ -20,7 +20,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
20
20
** Upgrading from uuid\@ 3?** Your code is probably okay, but check out [ Upgrading
21
21
From uuid\@ 3] ( #upgrading-from-uuid3 ) for details.
22
22
23
- ## Quickstart - Node.js/CommonJS
23
+ ## Quickstart
24
24
25
25
``` shell
26
26
npm install uuid
@@ -38,16 +38,25 @@ versions, all of which are supported here. In order of popularity, they are:
38
38
39
39
### Create Version 4 (Random) UUIDs
40
40
41
+ ECMAScript Module syntax:
42
+
41
43
``` javascript
42
44
import { v4 as uuidv4 } from ' uuid' ;
43
45
uuidv4 (); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
44
46
```
45
47
48
+ CommonJS syntax:
49
+
50
+ ``` javascript
51
+ const { v4: uuidv4 } = require (' uuid' );
52
+ uuidv4 (); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
53
+ ```
54
+
46
55
### Create Version 1 (Timestamp) UUIDs
47
56
48
57
``` javascript
49
58
import { v1 as uuidv1 } from ' uuid' ;
50
- uuidv1 (); // ⇨ '2c5ea4c0-4067-11e9-8b2d-1b9d6bcdbbfd '
59
+ uuidv1 (); // ⇨ '2c5ea4c0-4067-11e9-8bad-9b1deb4d3b7d '
51
60
```
52
61
53
62
### Create Version 3 or Version 5 (Namespace) UUIDs
@@ -133,17 +142,17 @@ Example: Generate two IDs in a single buffer
133
142
const buffer = new Array ();
134
143
uuidv4 (null , buffer, 0 ); // ⇨
135
144
// [
136
- // 155, 29, 235, 77, 59 ,
137
- // 125, 75, 173 , 155, 221 ,
138
- // 43, 13, 123, 61, 203 ,
139
- // 109
145
+ // 27, 157, 107, 205, 187 ,
146
+ // 253, 75, 45 , 155, 93 ,
147
+ // 171, 141, 251, 189, 75 ,
148
+ // 237
140
149
// ]
141
150
uuidv4 (null , buffer, 16 ); // ⇨
142
151
// [
143
- // 155, 29, 235, 77, 59, 125, 75, 173,
144
- // 155, 221, 43, 13, 123, 61, 203, 109,
145
152
// 27, 157, 107, 205, 187, 253, 75, 45,
146
- // 155, 93, 171, 141, 251, 189, 75, 237
153
+ // 155, 93, 171, 141, 251, 189, 75, 237,
154
+ // 155, 29, 235, 77, 59, 125, 75, 173,
155
+ // 155, 221, 43, 13, 123, 61, 203, 109
147
156
// ]
148
157
```
149
158
@@ -193,17 +202,16 @@ Example: In-place generation of two binary IDs
193
202
const arr = new Array ();
194
203
uuidv1 (null , arr, 0 ); // ⇨
195
204
// [
196
- // 44, 94, 164, 192, 64,
197
- // 103, 17, 233, 146, 52,
198
- // 27, 157, 107, 205, 187,
199
- // 253
205
+ // 44, 94, 164, 192, 64, 103,
206
+ // 17, 233, 146, 52, 155, 29,
207
+ // 235, 77, 59, 125
200
208
// ]
201
209
uuidv1 (null , arr, 16 ); // ⇨
202
210
// [
203
- // 44, 94, 164, 192, 64, 103, 17, 233,
204
- // 146, 52, 27, 157, 107, 205, 187, 253 ,
205
- // 44, 94, 164, 193, 64, 103, 17, 233,
206
- // 146, 52, 27, 157, 107, 205, 187, 253
211
+ // 44, 94, 164, 192, 64, 103, 17, 233,
212
+ // 146, 52, 155, 29, 235, 77, 59, 125 ,
213
+ // 44, 94, 164, 193, 64, 103, 17, 233,
214
+ // 146, 52, 155, 29, 235, 77, 59, 125
207
215
// ]
208
216
```
209
217
0 commit comments