uuid 3.2.0 → 3.3.3

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/CHANGELOG.md CHANGED
@@ -1,7 +1,55 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
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
4
 
5
+ ### [3.3.3](https://github.com/kelektiv/node-uuid/compare/v3.3.2...v3.3.3) (2019-08-19)
6
+
7
+ <a name="3.3.2"></a>
8
+ ## [3.3.2](https://github.com/kelektiv/node-uuid/compare/v3.3.1...v3.3.2) (2018-06-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * typo ([305d877](https://github.com/kelektiv/node-uuid/commit/305d877))
14
+
15
+
16
+
17
+ <a name="3.3.1"></a>
18
+ ## [3.3.1](https://github.com/kelektiv/node-uuid/compare/v3.3.0...v3.3.1) (2018-06-28)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * 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))
24
+
25
+
26
+
27
+ <a name="3.3.0"></a>
28
+ # [3.3.0](https://github.com/kelektiv/node-uuid/compare/v3.2.1...v3.3.0) (2018-06-22)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * 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))
34
+ * fix [#229](https://github.com/kelektiv/node-uuid/issues/229) ([c9684d4](https://github.com/kelektiv/node-uuid/commit/c9684d4))
35
+ * Get correct version of IE11 crypto ([#274](https://github.com/kelektiv/node-uuid/issues/274)) ([153d331](https://github.com/kelektiv/node-uuid/commit/153d331))
36
+ * mem issue when generating uuid ([#267](https://github.com/kelektiv/node-uuid/issues/267)) ([c47702c](https://github.com/kelektiv/node-uuid/commit/c47702c))
37
+
38
+ ### Features
39
+
40
+ * enforce Conventional Commit style commit messages ([#282](https://github.com/kelektiv/node-uuid/issues/282)) ([cc9a182](https://github.com/kelektiv/node-uuid/commit/cc9a182))
41
+
42
+
43
+ <a name="3.2.1"></a>
44
+ ## [3.2.1](https://github.com/kelektiv/node-uuid/compare/v3.2.0...v3.2.1) (2018-01-16)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * 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))
50
+
51
+
52
+
5
53
  <a name="3.2.0"></a>
6
54
  # [3.2.0](https://github.com/kelektiv/node-uuid/compare/v3.1.0...v3.2.0) (2018-01-16)
7
55
 
@@ -17,31 +65,48 @@ All notable changes to this project will be documented in this file. See [standa
17
65
  * Add v3 Support ([#217](https://github.com/kelektiv/node-uuid/issues/217)) ([d94f726](https://github.com/kelektiv/node-uuid/commit/d94f726))
18
66
 
19
67
 
68
+ # [3.1.0](https://github.com/kelektiv/node-uuid/compare/v3.1.0...v3.0.1) (2017-06-17)
69
+
70
+ ### Bug Fixes
71
+
72
+ * (fix) Add .npmignore file to exclude test/ and other non-essential files from packing. (#183)
73
+ * Fix typo (#178)
74
+ * Simple typo fix (#165)
75
+
76
+ ### Features
77
+ * v5 support in CLI (#197)
78
+ * V5 support (#188)
79
+
20
80
 
21
81
  # 3.0.1 (2016-11-28)
22
82
 
23
- * split uuid versions into separate files
83
+ * split uuid versions into separate files
84
+
24
85
 
25
86
  # 3.0.0 (2016-11-17)
26
87
 
27
- * remove .parse and .unparse
88
+ * remove .parse and .unparse
89
+
28
90
 
29
91
  # 2.0.0
30
92
 
31
- * Removed uuid.BufferClass
93
+ * Removed uuid.BufferClass
94
+
32
95
 
33
96
  # 1.4.0
34
97
 
35
- * Improved module context detection
36
- * Removed public RNG functions
98
+ * Improved module context detection
99
+ * Removed public RNG functions
100
+
37
101
 
38
102
  # 1.3.2
39
103
 
40
- * Improve tests and handling of v1() options (Issue #24)
41
- * Expose RNG option to allow for perf testing with different generators
104
+ * Improve tests and handling of v1() options (Issue #24)
105
+ * Expose RNG option to allow for perf testing with different generators
106
+
42
107
 
43
108
  # 1.3.0
44
109
 
45
- * Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
46
- * Support for node.js crypto API
47
- * De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
110
+ * Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
111
+ * Support for node.js crypto API
112
+ * De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
package/README.md CHANGED
@@ -28,7 +28,7 @@ Version 1 (timestamp):
28
28
 
29
29
  ```javascript
30
30
  const uuidv1 = require('uuid/v1');
31
- uuidv1(); // ⇨ 'cd4b78f0-facb-11e7-8ab9-db97a89e6c61'
31
+ uuidv1(); // ⇨ '2c5ea4c0-4067-11e9-8bad-9b1deb4d3b7d'
32
32
 
33
33
  ```
34
34
 
@@ -56,7 +56,7 @@ Version 4 (random):
56
56
 
57
57
  ```javascript
58
58
  const uuidv4 = require('uuid/v4');
59
- uuidv4(); // ⇨ '50fcd19b-5302-4b7b-97fd-92cabead0a6d'
59
+ uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
60
60
 
61
61
  ```
62
62
 
@@ -147,7 +147,7 @@ Generate and return a RFC4122 v1 (timestamp-based) UUID.
147
147
 
148
148
  Returns `buffer`, if specified, otherwise the string form of the UUID
149
149
 
150
- Note: The <node> id is generated guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)
150
+ Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
151
151
 
152
152
  Example: Generate string UUID with fully-specified options
153
153
 
@@ -167,8 +167,8 @@ Example: In-place generation of two binary IDs
167
167
  ```javascript
168
168
  // Generate two ids in an array
169
169
  const arr = new Array();
170
- uuidv1(null, arr, 0); // ⇨ [ 205, 84, 121, 160, 250, 203, 17, 231, 146, 52, 219, 151, 168, 158, 108, 97 ]
171
- uuidv1(null, arr, 16); // ⇨ [ 205, 84, 121, 160, 250, 203, 17, 231, 146, 52, 219, 151, 168, 158, 108, 97, 205, 84, 160, 176, 250, 203, 17, 231, 146, 52, 219, 151, 168, 158, 108, 97 ]
170
+ uuidv1(null, arr, 0); // ⇨ [ 44, 94, 164, 192, 64, 103, 17, 233, 146, 52, 155, 29, 235, 77, 59, 125 ]
171
+ uuidv1(null, arr, 16); // ⇨ [ 44, 94, 164, 192, 64, 103, 17, 233, 146, 52, 155, 29, 235, 77, 59, 125, 44, 94, 164, 193, 64, 103, 17, 233, 146, 52, 155, 29, 235, 77, 59, 125 ]
172
172
 
173
173
  ```
174
174
 
@@ -237,8 +237,8 @@ Example: Generate two IDs in a single buffer
237
237
 
238
238
  ```javascript
239
239
  const buffer = new Array();
240
- uuidv4(null, buffer, 0); // ⇨ [ 67, 176, 245, 14, 66, 213, 76, 211, 160, 194, 254, 30, 190, 20, 195, 236 ]
241
- uuidv4(null, buffer, 16); // ⇨ [ 67, 176, 245, 14, 66, 213, 76, 211, 160, 194, 254, 30, 190, 20, 195, 236, 25, 78, 246, 100, 115, 188, 70, 66, 185, 84, 18, 78, 23, 254, 174, 151 ]
240
+ uuidv4(null, buffer, 0); // ⇨ [ 155, 29, 235, 77, 59, 125, 75, 173, 155, 221, 43, 13, 123, 61, 203, 109 ]
241
+ uuidv4(null, buffer, 16); // ⇨ [ 155, 29, 235, 77, 59, 125, 75, 173, 155, 221, 43, 13, 123, 61, 203, 109, 27, 157, 107, 205, 187, 253, 75, 45, 155, 93, 171, 141, 251, 189, 75, 237 ]
242
242
 
243
243
  ```
244
244
 
@@ -10,14 +10,15 @@ for (var i = 0; i < 256; ++i) {
10
10
  function bytesToUuid(buf, offset) {
11
11
  var i = offset || 0;
12
12
  var bth = byteToHex;
13
- return bth[buf[i++]] + bth[buf[i++]] +
14
- bth[buf[i++]] + bth[buf[i++]] + '-' +
15
- bth[buf[i++]] + bth[buf[i++]] + '-' +
16
- bth[buf[i++]] + bth[buf[i++]] + '-' +
17
- bth[buf[i++]] + bth[buf[i++]] + '-' +
18
- bth[buf[i++]] + bth[buf[i++]] +
19
- bth[buf[i++]] + bth[buf[i++]] +
20
- bth[buf[i++]] + bth[buf[i++]];
13
+ // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
14
+ return ([bth[buf[i++]], bth[buf[i++]],
15
+ bth[buf[i++]], bth[buf[i++]], '-',
16
+ bth[buf[i++]], bth[buf[i++]], '-',
17
+ bth[buf[i++]], bth[buf[i++]], '-',
18
+ bth[buf[i++]], bth[buf[i++]], '-',
19
+ bth[buf[i++]], bth[buf[i++]],
20
+ bth[buf[i++]], bth[buf[i++]],
21
+ bth[buf[i++]], bth[buf[i++]]]).join('');
21
22
  }
22
23
 
23
24
  module.exports = bytesToUuid;
@@ -3,8 +3,11 @@
3
3
  // and inconsistent support for the `crypto` API. We do the best we can via
4
4
  // feature-detection
5
5
 
6
- var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues) ||
7
- (typeof(msCrypto) != 'undefined' && msCrypto.getRandomValues);
6
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto
7
+ // implementation. Also, find the complete implementation of crypto on IE11.
8
+ var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
9
+ (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
10
+
8
11
  if (getRandomValues) {
9
12
  // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
10
13
  var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
package/lib/v35.js CHANGED
@@ -43,7 +43,11 @@ module.exports = function(name, version, hashfunc) {
43
43
  return buf || bytesToUuid(bytes);
44
44
  };
45
45
 
46
- generateUUID.name = name;
46
+ // Function#name is not settable on some platforms (#270)
47
+ try {
48
+ generateUUID.name = name;
49
+ } catch (err) {
50
+ }
47
51
 
48
52
  // Pre-defined namespaces, per Appendix C
49
53
  generateUUID.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "3.2.0",
3
+ "version": "3.3.3",
4
4
  "description": "RFC4122 (v1, v4, and v5) UUIDs",
5
+ "commitlint": {
6
+ "extends": [
7
+ "@commitlint/config-conventional"
8
+ ]
9
+ },
5
10
  "keywords": [
6
11
  "uuid",
7
12
  "guid",
@@ -12,12 +17,16 @@
12
17
  "uuid": "./bin/uuid"
13
18
  },
14
19
  "devDependencies": {
15
- "eslint": "4.5.0",
16
- "mocha": "3.1.2",
17
- "runmd": "1.0.1",
18
- "standard-version": "4.2.0"
20
+ "@commitlint/cli": "8.1.0",
21
+ "@commitlint/config-conventional": "8.1.0",
22
+ "eslint": "6.2.0",
23
+ "husky": "3.0.4",
24
+ "mocha": "6.2.0",
25
+ "runmd": "1.2.1",
26
+ "standard-version": "7.0.0"
19
27
  },
20
28
  "scripts": {
29
+ "commitmsg": "commitlint -E HUSKY_GIT_PARAMS",
21
30
  "test": "mocha test/test.js",
22
31
  "md": "runmd --watch --output=README.md README_js.md",
23
32
  "release": "standard-version",
@@ -31,6 +40,5 @@
31
40
  "repository": {
32
41
  "type": "git",
33
42
  "url": "https://github.com/kelektiv/node-uuid.git"
34
- },
35
- "dependencies": {}
43
+ }
36
44
  }
package/.eslintrc.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "root": true,
3
- "env": {
4
- "browser": true,
5
- "commonjs": true,
6
- "node": true,
7
- "mocha": true
8
- },
9
- "extends": ["eslint:recommended"],
10
- "rules": {
11
- "array-bracket-spacing": ["warn", "never"],
12
- "arrow-body-style": ["warn", "as-needed"],
13
- "arrow-parens": ["warn", "as-needed"],
14
- "arrow-spacing": "warn",
15
- "brace-style": ["warn", "1tbs"],
16
- "camelcase": "warn",
17
- "comma-spacing": ["warn", {"after": true}],
18
- "dot-notation": "warn",
19
- "eqeqeq": ["warn", "smart"],
20
- "indent": ["warn", 2, {
21
- "SwitchCase": 1,
22
- "FunctionDeclaration": {"parameters": 1},
23
- "MemberExpression": 1,
24
- "CallExpression": {"arguments": 1}
25
- }],
26
- "key-spacing": ["warn", {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
27
- "keyword-spacing": "warn",
28
- "no-console": "off",
29
- "no-empty": "off",
30
- "no-multi-spaces": "warn",
31
- "no-redeclare": "off",
32
- "no-restricted-globals": ["warn", "Promise"],
33
- "no-trailing-spaces": "warn",
34
- "no-undef": "error",
35
- "no-unused-vars": ["warn", {"args": "none"}],
36
- "one-var": ["warn", "never"],
37
- "padded-blocks": ["warn", "never"],
38
- "object-curly-spacing": ["warn", "never"],
39
- "quotes": ["warn", "single"],
40
- "react/prop-types": "off",
41
- "react/jsx-no-bind": "off",
42
- "semi": ["warn", "always"],
43
- "space-before-blocks": ["warn", "always"],
44
- "space-before-function-paren": ["warn", "never"],
45
- "space-in-parens": ["warn", "never"]
46
- }
47
- }
package/README_js.md DELETED
@@ -1,280 +0,0 @@
1
- ```javascript --hide
2
- runmd.onRequire = path => path.replace(/^uuid/, './');
3
- ```
4
-
5
- # uuid [![Build Status](https://secure.travis-ci.org/kelektiv/node-uuid.svg?branch=master)](http://travis-ci.org/kelektiv/node-uuid) #
6
-
7
- Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
8
-
9
- Features:
10
-
11
- * Support for version 1, 3, 4 and 5 UUIDs
12
- * Cross-platform
13
- * Uses cryptographically-strong random number APIs (when available)
14
- * Zero-dependency, small footprint (... but not [this small](https://gist.github.com/982883))
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
-
19
- ## Quickstart - CommonJS (Recommended)
20
-
21
- ```shell
22
- npm install uuid
23
- ```
24
-
25
- Then generate your uuid version of choice ...
26
-
27
- Version 1 (timestamp):
28
-
29
- ```javascript --run v1
30
- const uuidv1 = require('uuid/v1');
31
- uuidv1(); // RESULT
32
- ```
33
-
34
- Version 3 (namespace):
35
-
36
- ```javascript --run v3
37
- const uuidv3 = require('uuid/v3');
38
-
39
- // ... using predefined DNS namespace (for domain names)
40
- uuidv3('hello.example.com', uuidv3.DNS); // RESULT
41
-
42
- // ... using predefined URL namespace (for, well, URLs)
43
- uuidv3('http://example.com/hello', uuidv3.URL); // RESULT
44
-
45
- // ... using a custom namespace
46
- //
47
- // Note: Custom namespaces should be a UUID string specific to your application!
48
- // E.g. the one here was generated using this modules `uuid` CLI.
49
- const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
50
- uuidv3('Hello, World!', MY_NAMESPACE); // RESULT
51
- ```
52
-
53
- Version 4 (random):
54
-
55
- ```javascript --run v4
56
- const uuidv4 = require('uuid/v4');
57
- uuidv4(); // RESULT
58
- ```
59
-
60
- Version 5 (namespace):
61
-
62
- ```javascript --run v5
63
- const uuidv5 = require('uuid/v5');
64
-
65
- // ... using predefined DNS namespace (for domain names)
66
- uuidv5('hello.example.com', uuidv5.DNS); // RESULT
67
-
68
- // ... using predefined URL namespace (for, well, URLs)
69
- uuidv5('http://example.com/hello', uuidv5.URL); // RESULT
70
-
71
- // ... using a custom namespace
72
- //
73
- // Note: Custom namespaces should be a UUID string specific to your application!
74
- // E.g. the one here was generated using this modules `uuid` CLI.
75
- const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
76
- uuidv5('Hello, World!', MY_NAMESPACE); // RESULT
77
- ```
78
-
79
- ## Quickstart - Browser-ready Versions
80
-
81
- Browser-ready versions of this module are available via [wzrd.in](https://github.com/jfhbrook/wzrd.in).
82
-
83
- For version 1 uuids:
84
-
85
- ```html
86
- <script src="http://wzrd.in/standalone/uuid%2Fv1@latest"></script>
87
- <script>
88
- uuidv1(); // -> v1 UUID
89
- </script>
90
- ```
91
-
92
- For version 3 uuids:
93
-
94
- ```html
95
- <script src="http://wzrd.in/standalone/uuid%2Fv3@latest"></script>
96
- <script>
97
- uuidv3('http://example.com/hello', uuidv3.URL); // -> v3 UUID
98
- </script>
99
- ```
100
-
101
- For version 4 uuids:
102
-
103
- ```html
104
- <script src="http://wzrd.in/standalone/uuid%2Fv4@latest"></script>
105
- <script>
106
- uuidv4(); // -> v4 UUID
107
- </script>
108
- ```
109
-
110
- For version 5 uuids:
111
-
112
- ```html
113
- <script src="http://wzrd.in/standalone/uuid%2Fv5@latest"></script>
114
- <script>
115
- uuidv5('http://example.com/hello', uuidv5.URL); // -> v5 UUID
116
- </script>
117
- ```
118
-
119
- ## API
120
-
121
- ### Version 1
122
-
123
- ```javascript
124
- const uuidv1 = require('uuid/v1');
125
-
126
- // Incantations
127
- uuidv1();
128
- uuidv1(options);
129
- uuidv1(options, buffer, offset);
130
- ```
131
-
132
- Generate and return a RFC4122 v1 (timestamp-based) UUID.
133
-
134
- * `options` - (Object) Optional uuid state to apply. Properties may include:
135
-
136
- * `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
137
- * `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
138
- * `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
139
- * `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.
140
-
141
- * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
142
- * `offset` - (Number) Starting index in `buffer` at which to begin writing.
143
-
144
- Returns `buffer`, if specified, otherwise the string form of the UUID
145
-
146
- Note: The <node> id is generated guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)
147
-
148
- Example: Generate string UUID with fully-specified options
149
-
150
- ```javascript --run v1
151
- const v1options = {
152
- node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
153
- clockseq: 0x1234,
154
- msecs: new Date('2011-11-01').getTime(),
155
- nsecs: 5678
156
- };
157
- uuidv1(v1options); // RESULT
158
- ```
159
-
160
- Example: In-place generation of two binary IDs
161
-
162
- ```javascript --run v1
163
- // Generate two ids in an array
164
- const arr = new Array();
165
- uuidv1(null, arr, 0); // RESULT
166
- uuidv1(null, arr, 16); // RESULT
167
- ```
168
-
169
- ### Version 3
170
-
171
- ```javascript
172
- const uuidv3 = require('uuid/v3');
173
-
174
- // Incantations
175
- uuidv3(name, namespace);
176
- uuidv3(name, namespace, buffer);
177
- uuidv3(name, namespace, buffer, offset);
178
- ```
179
-
180
- Generate and return a RFC4122 v3 UUID.
181
-
182
- * `name` - (String | Array[]) "name" to create UUID with
183
- * `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
184
- * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
185
- * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
186
-
187
- Returns `buffer`, if specified, otherwise the string form of the UUID
188
-
189
- Example:
190
-
191
- ```javascript --run v3
192
- uuidv3('hello world', MY_NAMESPACE); // RESULT
193
- ```
194
-
195
- ### Version 4
196
-
197
- ```javascript
198
- const uuidv4 = require('uuid/v4')
199
-
200
- // Incantations
201
- uuidv4();
202
- uuidv4(options);
203
- uuidv4(options, buffer, offset);
204
- ```
205
-
206
- Generate and return a RFC4122 v4 UUID.
207
-
208
- * `options` - (Object) Optional uuid state to apply. Properties may include:
209
- * `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values
210
- * `rng` - (Function) Random # generator function that returns an Array[16] of byte values (0-255)
211
- * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
212
- * `offset` - (Number) Starting index in `buffer` at which to begin writing.
213
-
214
- Returns `buffer`, if specified, otherwise the string form of the UUID
215
-
216
- Example: Generate string UUID with predefined `random` values
217
-
218
- ```javascript --run v4
219
- const v4options = {
220
- random: [
221
- 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
222
- 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
223
- ]
224
- };
225
- uuidv4(v4options); // RESULT
226
- ```
227
-
228
- Example: Generate two IDs in a single buffer
229
-
230
- ```javascript --run v4
231
- const buffer = new Array();
232
- uuidv4(null, buffer, 0); // RESULT
233
- uuidv4(null, buffer, 16); // RESULT
234
- ```
235
-
236
- ### Version 5
237
-
238
- ```javascript
239
- const uuidv5 = require('uuid/v5');
240
-
241
- // Incantations
242
- uuidv5(name, namespace);
243
- uuidv5(name, namespace, buffer);
244
- uuidv5(name, namespace, buffer, offset);
245
- ```
246
-
247
- Generate and return a RFC4122 v5 UUID.
248
-
249
- * `name` - (String | Array[]) "name" to create UUID with
250
- * `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
251
- * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
252
- * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
253
-
254
- Returns `buffer`, if specified, otherwise the string form of the UUID
255
-
256
- Example:
257
-
258
- ```javascript --run v5
259
- uuidv5('hello world', MY_NAMESPACE); // RESULT
260
- ```
261
-
262
- ## Command Line
263
-
264
- UUIDs can be generated from the command line with the `uuid` command.
265
-
266
- ```shell
267
- $ uuid
268
- ddeb27fb-d9a0-4624-be4d-4615062daed4
269
-
270
- $ uuid v1
271
- 02d37060-d446-11e7-a9fa-7bdae751ebe1
272
- ```
273
-
274
- Type `uuid --help` for usage details
275
-
276
- ## Testing
277
-
278
- ```shell
279
- npm test
280
- ```