uuid 3.1.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -7,16 +7,16 @@
7
7
  "mocha": true
8
8
  },
9
9
  "extends": ["eslint:recommended"],
10
- "installedESLint": true,
11
10
  "rules": {
12
11
  "array-bracket-spacing": ["warn", "never"],
13
12
  "arrow-body-style": ["warn", "as-needed"],
14
13
  "arrow-parens": ["warn", "as-needed"],
15
14
  "arrow-spacing": "warn",
16
- "brace-style": "warn",
15
+ "brace-style": ["warn", "1tbs"],
17
16
  "camelcase": "warn",
18
17
  "comma-spacing": ["warn", {"after": true}],
19
18
  "dot-notation": "warn",
19
+ "eqeqeq": ["warn", "smart"],
20
20
  "indent": ["warn", 2, {
21
21
  "SwitchCase": 1,
22
22
  "FunctionDeclaration": {"parameters": 1},
@@ -33,6 +33,7 @@
33
33
  "no-trailing-spaces": "warn",
34
34
  "no-undef": "error",
35
35
  "no-unused-vars": ["warn", {"args": "none"}],
36
+ "one-var": ["warn", "never"],
36
37
  "padded-blocks": ["warn", "never"],
37
38
  "object-curly-spacing": ["warn", "never"],
38
39
  "quotes": ["warn", "single"],
package/CHANGELOG.md ADDED
@@ -0,0 +1,110 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ <a name="3.3.2"></a>
6
+ ## [3.3.2](https://github.com/kelektiv/node-uuid/compare/v3.3.1...v3.3.2) (2018-06-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * typo ([305d877](https://github.com/kelektiv/node-uuid/commit/305d877))
12
+
13
+
14
+
15
+ <a name="3.3.1"></a>
16
+ ## [3.3.1](https://github.com/kelektiv/node-uuid/compare/v3.3.0...v3.3.1) (2018-06-28)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * fix [#284](https://github.com/kelektiv/node-uuid/issues/284) by setting function name in try-catch ([f2a60f2](https://github.com/kelektiv/node-uuid/commit/f2a60f2))
22
+
23
+
24
+
25
+ <a name="3.3.0"></a>
26
+ # [3.3.0](https://github.com/kelektiv/node-uuid/compare/v3.2.1...v3.3.0) (2018-06-22)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * assignment to readonly property to allow running in strict mode ([#270](https://github.com/kelektiv/node-uuid/issues/270)) ([d062fdc](https://github.com/kelektiv/node-uuid/commit/d062fdc))
32
+ * fix [#229](https://github.com/kelektiv/node-uuid/issues/229) ([c9684d4](https://github.com/kelektiv/node-uuid/commit/c9684d4))
33
+ * Get correct version of IE11 crypto ([#274](https://github.com/kelektiv/node-uuid/issues/274)) ([153d331](https://github.com/kelektiv/node-uuid/commit/153d331))
34
+ * mem issue when generating uuid ([#267](https://github.com/kelektiv/node-uuid/issues/267)) ([c47702c](https://github.com/kelektiv/node-uuid/commit/c47702c))
35
+
36
+ ### Features
37
+
38
+ * enforce Conventional Commit style commit messages ([#282](https://github.com/kelektiv/node-uuid/issues/282)) ([cc9a182](https://github.com/kelektiv/node-uuid/commit/cc9a182))
39
+
40
+
41
+ <a name="3.2.1"></a>
42
+ ## [3.2.1](https://github.com/kelektiv/node-uuid/compare/v3.2.0...v3.2.1) (2018-01-16)
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * use msCrypto if available. Fixes [#241](https://github.com/kelektiv/node-uuid/issues/241) ([#247](https://github.com/kelektiv/node-uuid/issues/247)) ([1fef18b](https://github.com/kelektiv/node-uuid/commit/1fef18b))
48
+
49
+
50
+
51
+ <a name="3.2.0"></a>
52
+ # [3.2.0](https://github.com/kelektiv/node-uuid/compare/v3.1.0...v3.2.0) (2018-01-16)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * remove mistakenly added typescript dependency, rollback version (standard-version will auto-increment) ([09fa824](https://github.com/kelektiv/node-uuid/commit/09fa824))
58
+ * use msCrypto if available. Fixes [#241](https://github.com/kelektiv/node-uuid/issues/241) ([#247](https://github.com/kelektiv/node-uuid/issues/247)) ([1fef18b](https://github.com/kelektiv/node-uuid/commit/1fef18b))
59
+
60
+
61
+ ### Features
62
+
63
+ * Add v3 Support ([#217](https://github.com/kelektiv/node-uuid/issues/217)) ([d94f726](https://github.com/kelektiv/node-uuid/commit/d94f726))
64
+
65
+
66
+ # [3.1.0](https://github.com/kelektiv/node-uuid/compare/v3.1.0...v3.0.1) (2017-06-17)
67
+
68
+ ### Bug Fixes
69
+
70
+ * (fix) Add .npmignore file to exclude test/ and other non-essential files from packing. (#183)
71
+ * Fix typo (#178)
72
+ * Simple typo fix (#165)
73
+
74
+ ### Features
75
+ * v5 support in CLI (#197)
76
+ * V5 support (#188)
77
+
78
+
79
+ # 3.0.1 (2016-11-28)
80
+
81
+ * split uuid versions into separate files
82
+
83
+
84
+ # 3.0.0 (2016-11-17)
85
+
86
+ * remove .parse and .unparse
87
+
88
+
89
+ # 2.0.0
90
+
91
+ * Removed uuid.BufferClass
92
+
93
+
94
+ # 1.4.0
95
+
96
+ * Improved module context detection
97
+ * Removed public RNG functions
98
+
99
+
100
+ # 1.3.2
101
+
102
+ * Improve tests and handling of v1() options (Issue #24)
103
+ * Expose RNG option to allow for perf testing with different generators
104
+
105
+
106
+ # 1.3.0
107
+
108
+ * Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
109
+ * Support for node.js crypto API
110
+ * De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
package/README.md CHANGED
@@ -1,14 +1,21 @@
1
+ <!--
2
+ -- This file is auto-generated from README_js.md. Changes should be made there.
3
+ -->
4
+
1
5
  # uuid [![Build Status](https://secure.travis-ci.org/kelektiv/node-uuid.svg?branch=master)](http://travis-ci.org/kelektiv/node-uuid) #
2
6
 
3
7
  Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
4
8
 
5
9
  Features:
6
10
 
7
- * Support for version 1, 4 and 5 UUIDs
11
+ * Support for version 1, 3, 4 and 5 UUIDs
8
12
  * Cross-platform
9
13
  * Uses cryptographically-strong random number APIs (when available)
10
14
  * Zero-dependency, small footprint (... but not [this small](https://gist.github.com/982883))
11
15
 
16
+ [**Deprecation warning**: The use of `require('uuid')` is deprecated and will not be
17
+ supported after version 3.x of this module. Instead, use `require('uuid/[v1|v3|v4|v5]')` as shown in the examples below.]
18
+
12
19
  ## Quickstart - CommonJS (Recommended)
13
20
 
14
21
  ```shell
@@ -21,14 +28,36 @@ Version 1 (timestamp):
21
28
 
22
29
  ```javascript
23
30
  const uuidv1 = require('uuid/v1');
24
- uuidv1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
31
+ uuidv1(); // '45745c60-7b1a-11e8-9c9c-2d42b21b1a3e'
32
+
33
+ ```
34
+
35
+ Version 3 (namespace):
36
+
37
+ ```javascript
38
+ const uuidv3 = require('uuid/v3');
39
+
40
+ // ... using predefined DNS namespace (for domain names)
41
+ uuidv3('hello.example.com', uuidv3.DNS); // ⇨ '9125a8dc-52ee-365b-a5aa-81b0b3681cf6'
42
+
43
+ // ... using predefined URL namespace (for, well, URLs)
44
+ uuidv3('http://example.com/hello', uuidv3.URL); // ⇨ 'c6235813-3ba4-3801-ae84-e0a6ebb7d138'
45
+
46
+ // ... using a custom namespace
47
+ //
48
+ // Note: Custom namespaces should be a UUID string specific to your application!
49
+ // E.g. the one here was generated using this modules `uuid` CLI.
50
+ const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
51
+ uuidv3('Hello, World!', MY_NAMESPACE); // ⇨ 'e8b5a51d-11c8-3310-a6ab-367563f20686'
52
+
25
53
  ```
26
54
 
27
55
  Version 4 (random):
28
56
 
29
57
  ```javascript
30
58
  const uuidv4 = require('uuid/v4');
31
- uuidv4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
59
+ uuidv4(); // '10ba038e-48da-487b-96e8-8d3b99b6d18a'
60
+
32
61
  ```
33
62
 
34
63
  Version 5 (namespace):
@@ -37,14 +66,18 @@ Version 5 (namespace):
37
66
  const uuidv5 = require('uuid/v5');
38
67
 
39
68
  // ... using predefined DNS namespace (for domain names)
40
- uuidv5('hello.example.com', uuidv5.DNS)); // -> 'fdda765f-fc57-5604-a269-52a7df8164ec'
69
+ uuidv5('hello.example.com', uuidv5.DNS); // 'fdda765f-fc57-5604-a269-52a7df8164ec'
41
70
 
42
71
  // ... using predefined URL namespace (for, well, URLs)
43
- uuidv5('http://example.com/hello', uuidv5.URL); // -> '3bbcee75-cecc-5b56-8031-b6641c1ed1f1'
72
+ uuidv5('http://example.com/hello', uuidv5.URL); // '3bbcee75-cecc-5b56-8031-b6641c1ed1f1'
44
73
 
45
74
  // ... using a custom namespace
46
- const MY_NAMESPACE = '<UUID string you previously generated elsewhere>';
47
- uuidv5('Hello, World!', MY_NAMESPACE); // -> '90123e1c-7512-523e-bb28-76fab9f2f73d'
75
+ //
76
+ // Note: Custom namespaces should be a UUID string specific to your application!
77
+ // E.g. the one here was generated using this modules `uuid` CLI.
78
+ const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
79
+ uuidv5('Hello, World!', MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681'
80
+
48
81
  ```
49
82
 
50
83
  ## Quickstart - Browser-ready Versions
@@ -60,6 +93,15 @@ uuidv1(); // -> v1 UUID
60
93
  </script>
61
94
  ```
62
95
 
96
+ For version 3 uuids:
97
+
98
+ ```html
99
+ <script src="http://wzrd.in/standalone/uuid%2Fv3@latest"></script>
100
+ <script>
101
+ uuidv3('http://example.com/hello', uuidv3.URL); // -> v3 UUID
102
+ </script>
103
+ ```
104
+
63
105
  For version 4 uuids:
64
106
 
65
107
  ```html
@@ -85,7 +127,7 @@ uuidv5('http://example.com/hello', uuidv5.URL); // -> v5 UUID
85
127
  ```javascript
86
128
  const uuidv1 = require('uuid/v1');
87
129
 
88
- // Allowed arguments
130
+ // Incantations
89
131
  uuidv1();
90
132
  uuidv1(options);
91
133
  uuidv1(options, buffer, offset);
@@ -97,7 +139,7 @@ Generate and return a RFC4122 v1 (timestamp-based) UUID.
97
139
 
98
140
  * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
99
141
  * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
100
- * `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
142
+ * `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
101
143
  * `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.
102
144
 
103
145
  * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
@@ -110,21 +152,51 @@ Note: The <node> id is generated guaranteed to stay constant for the lifetime of
110
152
  Example: Generate string UUID with fully-specified options
111
153
 
112
154
  ```javascript
113
- uuidv1({
155
+ const v1options = {
114
156
  node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
115
157
  clockseq: 0x1234,
116
158
  msecs: new Date('2011-11-01').getTime(),
117
159
  nsecs: 5678
118
- }); // -> "710b962e-041c-11e1-9234-0123456789ab"
160
+ };
161
+ uuidv1(v1options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
162
+
119
163
  ```
120
164
 
121
165
  Example: In-place generation of two binary IDs
122
166
 
123
167
  ```javascript
124
168
  // Generate two ids in an array
125
- const arr = new Array(32); // -> []
126
- uuidv1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
127
- uuidv1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
169
+ const arr = new Array();
170
+ uuidv1(null, arr, 0); // [ 69, 117, 109, 208, 123, 26, 17, 232, 146, 52, 45, 66, 178, 27, 26, 62 ]
171
+ uuidv1(null, arr, 16); // [ 69, 117, 109, 208, 123, 26, 17, 232, 146, 52, 45, 66, 178, 27, 26, 62, 69, 117, 109, 209, 123, 26, 17, 232, 146, 52, 45, 66, 178, 27, 26, 62 ]
172
+
173
+ ```
174
+
175
+ ### Version 3
176
+
177
+ ```javascript
178
+ const uuidv3 = require('uuid/v3');
179
+
180
+ // Incantations
181
+ uuidv3(name, namespace);
182
+ uuidv3(name, namespace, buffer);
183
+ uuidv3(name, namespace, buffer, offset);
184
+ ```
185
+
186
+ Generate and return a RFC4122 v3 UUID.
187
+
188
+ * `name` - (String | Array[]) "name" to create UUID with
189
+ * `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
190
+ * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
191
+ * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
192
+
193
+ Returns `buffer`, if specified, otherwise the string form of the UUID
194
+
195
+ Example:
196
+
197
+ ```javascript
198
+ uuidv3('hello world', MY_NAMESPACE); // ⇨ '042ffd34-d989-321c-ad06-f60826172424'
199
+
128
200
  ```
129
201
 
130
202
  ### Version 4
@@ -132,7 +204,7 @@ uuidv1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 0
132
204
  ```javascript
133
205
  const uuidv4 = require('uuid/v4')
134
206
 
135
- // Allowed arguments
207
+ // Incantations
136
208
  uuidv4();
137
209
  uuidv4(options);
138
210
  uuidv4(options, buffer, offset);
@@ -148,38 +220,40 @@ Generate and return a RFC4122 v4 UUID.
148
220
 
149
221
  Returns `buffer`, if specified, otherwise the string form of the UUID
150
222
 
151
- Example: Generate string UUID with fully-specified options
223
+ Example: Generate string UUID with predefined `random` values
152
224
 
153
225
  ```javascript
154
- uuid.v4({
226
+ const v4options = {
155
227
  random: [
156
228
  0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
157
229
  0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
158
230
  ]
159
- });
160
- // -> "109156be-c4fb-41ea-b1b4-efe1671c5836"
231
+ };
232
+ uuidv4(v4options); // '109156be-c4fb-41ea-b1b4-efe1671c5836'
233
+
161
234
  ```
162
235
 
163
236
  Example: Generate two IDs in a single buffer
164
237
 
165
238
  ```javascript
166
- const buffer = new Array(32); // (or 'new Buffer' in node.js)
167
- uuid.v4(null, buffer, 0);
168
- uuid.v4(null, buffer, 16);
239
+ const buffer = new Array();
240
+ uuidv4(null, buffer, 0); // ⇨ [ 54, 122, 218, 70, 45, 70, 65, 24, 171, 53, 95, 130, 83, 195, 242, 45 ]
241
+ uuidv4(null, buffer, 16); // ⇨ [ 54, 122, 218, 70, 45, 70, 65, 24, 171, 53, 95, 130, 83, 195, 242, 45, 108, 204, 255, 103, 171, 86, 76, 94, 178, 225, 188, 236, 150, 20, 151, 87 ]
242
+
169
243
  ```
170
244
 
171
245
  ### Version 5
172
246
 
173
247
  ```javascript
174
- const uuidv5 = require('uuid/v4');
248
+ const uuidv5 = require('uuid/v5');
175
249
 
176
- // Allowed arguments
250
+ // Incantations
177
251
  uuidv5(name, namespace);
178
252
  uuidv5(name, namespace, buffer);
179
253
  uuidv5(name, namespace, buffer, offset);
180
254
  ```
181
255
 
182
- Generate and return a RFC4122 v4 UUID.
256
+ Generate and return a RFC4122 v5 UUID.
183
257
 
184
258
  * `name` - (String | Array[]) "name" to create UUID with
185
259
  * `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
@@ -191,37 +265,29 @@ Returns `buffer`, if specified, otherwise the string form of the UUID
191
265
  Example:
192
266
 
193
267
  ```javascript
194
- // Generate a unique namespace (typically you would do this once, outside of
195
- // your project, then bake this value into your code)
196
- const uuidv4 = require('uuid/v4');
197
- const MY_NAMESPACE = uuidv4(); //
268
+ uuidv5('hello world', MY_NAMESPACE); // '9f282611-e0fd-5650-8953-89c8e342da0b'
198
269
 
199
- // Generate a couple namespace uuids
200
- const uuidv5 = require('uuid/v5');
201
- uuidv5('hello', MY_NAMESPACE);
202
- uuidv5('world', MY_NAMESPACE);
203
270
  ```
204
271
 
205
- ## Testing
272
+ ## Command Line
206
273
 
207
- ```shell
208
- npm test
209
- ```
274
+ UUIDs can be generated from the command line with the `uuid` command.
210
275
 
211
- ## Deprecated / Browser-ready API
276
+ ```shell
277
+ $ uuid
278
+ ddeb27fb-d9a0-4624-be4d-4615062daed4
212
279
 
213
- The API below is available for legacy purposes and is not expected to be available post-3.X
280
+ $ uuid v1
281
+ 02d37060-d446-11e7-a9fa-7bdae751ebe1
282
+ ```
214
283
 
215
- ```javascript
216
- const uuid = require('uuid');
284
+ Type `uuid --help` for usage details
217
285
 
218
- uuid.v1(...); // alias of uuid/v1
219
- uuid.v4(...); // alias of uuid/v4
220
- uuid(...); // alias of uuid/v4
286
+ ## Testing
221
287
 
222
- // uuid.v5() is not supported in this API
288
+ ```shell
289
+ npm test
223
290
  ```
224
291
 
225
- ## Legacy node-uuid package
226
-
227
- The code for the legacy node-uuid package is available in the `node-uuid` branch.
292
+ ----
293
+ Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)