Skip to content

Commit 67d697c

Browse files
authoredJan 16, 2018
Fix #248 (#251)
* fix: README, to remove msecs arg allowing Date objects. Fixes #248 * fix: Update to runmd@1.0.1
1 parent 1fef18b commit 67d697c

File tree

3 files changed

+88
-21
lines changed

3 files changed

+88
-21
lines changed
 

‎README.md

+78-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
<!--
2+
-- This file is auto-generated from README_js.md. Changes should be made there.
3+
-->
14

25
# uuid [![Build Status](https://secure.travis-ci.org/kelektiv/node-uuid.svg?branch=master)](http://travis-ci.org/kelektiv/node-uuid) #
36

47
Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
58

69
Features:
710

8-
* Support for version 1, 4 and 5 UUIDs
11+
* Support for version 1, 3, 4 and 5 UUIDs
912
* Cross-platform
1013
* Uses cryptographically-strong random number APIs (when available)
1114
* Zero-dependency, small footprint (... but not [this small](https://gist.github.com/982883))
@@ -22,15 +25,35 @@ Version 1 (timestamp):
2225

2326
```javascript
2427
const uuidv1 = require('uuid/v1');
25-
uuidv1(); // ⇨ '985123a0-7e4f-11e7-9022-fb7190c856e4'
28+
uuidv1(); // ⇨ '47185630-f1a3-11e7-905e-bd5b5ba09b1f'
29+
30+
```
31+
32+
Version 3 (namespace):
33+
34+
```javascript
35+
const uuidv3 = require('uuid/v3');
36+
37+
// ... using predefined DNS namespace (for domain names)
38+
uuidv3('hello.example.com', uuidv3.DNS); // ⇨ '9125a8dc-52ee-365b-a5aa-81b0b3681cf6'
39+
40+
// ... using predefined URL namespace (for, well, URLs)
41+
uuidv3('http://example.com/hello', uuidv3.URL); // ⇨ 'c6235813-3ba4-3801-ae84-e0a6ebb7d138'
42+
43+
// ... using a custom namespace
44+
//
45+
// Note: Custom namespaces should be a UUID string specific to your application!
46+
// E.g. the one here was generated using this modules `uuid` CLI.
47+
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
48+
uuidv3('Hello, World!', MY_NAMESPACE); // ⇨ 'e8b5a51d-11c8-3310-a6ab-367563f20686'
2649

2750
```
2851

2952
Version 4 (random):
3053

3154
```javascript
3255
const uuidv4 = require('uuid/v4');
33-
uuidv4(); // ⇨ 'df7cca36-3d7a-40f4-8f06-ae03cc22f045'
56+
uuidv4(); // ⇨ 'b2857f0d-d2f4-46f0-9bf4-0dbcf0a13c1f'
3457

3558
```
3659

@@ -67,6 +90,15 @@ uuidv1(); // -> v1 UUID
6790
</script>
6891
```
6992

93+
For version 3 uuids:
94+
95+
```html
96+
<script src="http://wzrd.in/standalone/uuid%2Fv3@latest"></script>
97+
<script>
98+
uuidv3('http://example.com/hello', uuidv3.URL); // -> v3 UUID
99+
</script>
100+
```
101+
70102
For version 4 uuids:
71103

72104
```html
@@ -104,7 +136,7 @@ Generate and return a RFC4122 v1 (timestamp-based) UUID.
104136

105137
* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
106138
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
107-
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
139+
* `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
108140
* `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
109141

110142
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
@@ -132,8 +164,43 @@ Example: In-place generation of two binary IDs
132164
```javascript
133165
// Generate two ids in an array
134166
const arr = new Array();
135-
uuidv1(null, arr, 0); // ⇨ [ 152, 81, 152, 208, 126, 79, 17, 231, 146, 52, 251, 113, 144, 200, 86, 228 ]
136-
uuidv1(null, arr, 16); // ⇨ [ 152, 81, 152, 208, 126, 79, 17, 231, 146, 52, 251, 113, 144, 200, 86, 228, 152, 81, 191, 224, 126, 79, 17, 231, 146, 52, 251, 113, 144, 200, 86, 228 ]
167+
uuidv1(null, arr, 0); // ⇨ [ 71, 30, 112, 176, 241, 163, 17, 231, 146, 52, 189, 91, 91, 160, 155, 31 ]
168+
uuidv1(null, arr, 16); // ⇨ [ 71, 30, 112, 176, 241, 163, 17, 231, 146, 52, 189, 91, 91, 160, 155, 31, 71, 30, 151, 192, 241, 163, 17, 231, 146, 52, 189, 91, 91, 160, 155, 31 ]
169+
170+
```
171+
172+
### Version 3
173+
174+
```javascript
175+
const uuidv3 = require('uuid/v3');
176+
177+
// Incantations
178+
uuidv3(name, namespace);
179+
uuidv3(name, namespace, buffer);
180+
uuidv3(name, namespace, buffer, offset);
181+
```
182+
183+
Generate and return a RFC4122 v3 UUID.
184+
185+
* `name` - (String | Array[]) "name" to create UUID with
186+
* `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
187+
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
188+
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
189+
190+
Returns `buffer`, if specified, otherwise the string form of the UUID
191+
192+
Example:
193+
194+
```javascript
195+
// Generate a unique namespace (typically you would do this once, outside of
196+
// your project, then bake this value into your code)
197+
const uuidv4 = require('uuid/v4');
198+
const uuidv3 = require('uuid/v3');
199+
const MY_NAMESPACE = uuidv4(); // ⇨ '029f3419-d770-48bc-8862-5efd8eef925d'
200+
201+
// Generate a couple namespace uuids
202+
uuidv3('hello', MY_NAMESPACE); // ⇨ 'be216b77-2b79-3713-99af-a0add9d751f2'
203+
uuidv3('world', MY_NAMESPACE); // ⇨ '834a3f0c-30bd-35f7-a090-c718e1db7c56'
137204

138205
```
139206

@@ -175,8 +242,8 @@ Example: Generate two IDs in a single buffer
175242

176243
```javascript
177244
const buffer = new Array();
178-
uuidv4(null, buffer, 0); // ⇨ [ 217, 119, 223, 141, 202, 93, 66, 3, 178, 198, 149, 37, 232, 4, 107, 241 ]
179-
uuidv4(null, buffer, 16); // ⇨ [ 217, 119, 223, 141, 202, 93, 66, 3, 178, 198, 149, 37, 232, 4, 107, 241, 218, 189, 231, 45, 208, 56, 70, 125, 142, 27, 46, 27, 183, 9, 8, 202 ]
245+
uuidv4(null, buffer, 0); // ⇨ [ 36, 127, 174, 168, 247, 125, 67, 114, 180, 253, 89, 117, 13, 63, 184, 208 ]
246+
uuidv4(null, buffer, 16); // ⇨ [ 36, 127, 174, 168, 247, 125, 67, 114, 180, 253, 89, 117, 13, 63, 184, 208, 102, 253, 188, 241, 13, 225, 74, 91, 144, 239, 74, 141, 106, 12, 26, 70 ]
180247

181248
```
182249

@@ -207,11 +274,11 @@ Example:
207274
// your project, then bake this value into your code)
208275
const uuidv4 = require('uuid/v4');
209276
const uuidv5 = require('uuid/v5');
210-
const MY_NAMESPACE = uuidv4(); // ⇨ '8dc079dd-0313-4563-864f-008eb45bf87f'
277+
const MY_NAMESPACE = uuidv4(); // ⇨ 'e91f9e1b-ccfe-4eef-a9e0-7a0f4b229cb1'
211278

212279
// Generate a couple namespace uuids
213-
uuidv5('hello', MY_NAMESPACE); // ⇨ 'c506b68b-ed29-5662-bb90-7f43e624e333'
214-
uuidv5('world', MY_NAMESPACE); // ⇨ '669a6357-2584-534e-84bb-ac69f1c8ef44'
280+
uuidv5('hello', MY_NAMESPACE); // ⇨ 'c21bd5d3-295c-5d0f-8dee-b8d31738cd5c'
281+
uuidv5('world', MY_NAMESPACE); // ⇨ '3ca60bff-5f02-5cd0-a973-747019bb671f'
215282

216283
```
217284

‎README_js.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Then generate your uuid version of choice ...
2323

2424
Version 1 (timestamp):
2525

26-
```javascript --context
26+
```javascript --run uuid
2727
const uuidv1 = require('uuid/v1');
2828
uuidv1(); // RESULT
2929
```
3030

3131
Version 3 (namespace):
3232

33-
```javascript --context
33+
```javascript --run v3
3434
const uuidv3 = require('uuid/v3');
3535

3636
// ... using predefined DNS namespace (for domain names)
@@ -49,14 +49,14 @@ uuidv3('Hello, World!', MY_NAMESPACE); // RESULT
4949

5050
Version 4 (random):
5151

52-
```javascript --context
52+
```javascript --run uuid
5353
const uuidv4 = require('uuid/v4');
5454
uuidv4(); // RESULT
5555
```
5656

5757
Version 5 (namespace):
5858

59-
```javascript --context
59+
```javascript --run v5
6060
const uuidv5 = require('uuid/v5');
6161

6262
// ... using predefined DNS namespace (for domain names)
@@ -132,7 +132,7 @@ Generate and return a RFC4122 v1 (timestamp-based) UUID.
132132

133133
* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
134134
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
135-
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
135+
* `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
136136
* `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
137137

138138
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
@@ -144,7 +144,7 @@ Note: The <node> id is generated guaranteed to stay constant for the lifetime of
144144

145145
Example: Generate string UUID with fully-specified options
146146

147-
```javascript --context
147+
```javascript --run uuid
148148
const v1options = {
149149
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
150150
clockseq: 0x1234,
@@ -156,7 +156,7 @@ uuidv1(v1options); // RESULT
156156

157157
Example: In-place generation of two binary IDs
158158

159-
```javascript --context
159+
```javascript --run uuid
160160
// Generate two ids in an array
161161
const arr = new Array();
162162
uuidv1(null, arr, 0); // RESULT
@@ -220,7 +220,7 @@ Returns `buffer`, if specified, otherwise the string form of the UUID
220220

221221
Example: Generate string UUID with predefined `random` values
222222

223-
```javascript --context
223+
```javascript --run uuid
224224
const v4options = {
225225
random: [
226226
0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
@@ -232,7 +232,7 @@ uuidv4(v4options); // RESULT
232232

233233
Example: Generate two IDs in a single buffer
234234

235-
```javascript --context
235+
```javascript --run uuid
236236
const buffer = new Array();
237237
uuidv4(null, buffer, 0); // RESULT
238238
uuidv4(null, buffer, 16); // RESULT

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"devDependencies": {
1515
"eslint": "4.5.0",
1616
"mocha": "3.1.2",
17-
"runmd": "0.1.7"
17+
"runmd": "1.0.1"
1818
},
1919
"scripts": {
2020
"test": "mocha test/test.js",

0 commit comments

Comments
 (0)
Please sign in to comment.