Skip to content

Commit

Permalink
Fix #248 (#251)
Browse files Browse the repository at this point in the history
* fix: README, to remove msecs arg allowing Date objects.  Fixes #248

* fix: Update to runmd@1.0.1
  • Loading branch information
broofa committed Jan 16, 2018
1 parent 1fef18b commit 67d697c
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 21 deletions.
89 changes: 78 additions & 11 deletions README.md
@@ -1,11 +1,14 @@
<!--
-- This file is auto-generated from README_js.md. Changes should be made there.
-->

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

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

Features:

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

```javascript
const uuidv1 = require('uuid/v1');
uuidv1(); // ⇨ '985123a0-7e4f-11e7-9022-fb7190c856e4'
uuidv1(); // ⇨ '47185630-f1a3-11e7-905e-bd5b5ba09b1f'

```

Version 3 (namespace):

```javascript
const uuidv3 = require('uuid/v3');

// ... using predefined DNS namespace (for domain names)
uuidv3('hello.example.com', uuidv3.DNS); // ⇨ '9125a8dc-52ee-365b-a5aa-81b0b3681cf6'

// ... using predefined URL namespace (for, well, URLs)
uuidv3('http://example.com/hello', uuidv3.URL); // ⇨ 'c6235813-3ba4-3801-ae84-e0a6ebb7d138'

// ... using a custom namespace
//
// Note: Custom namespaces should be a UUID string specific to your application!
// E.g. the one here was generated using this modules `uuid` CLI.
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
uuidv3('Hello, World!', MY_NAMESPACE); // ⇨ 'e8b5a51d-11c8-3310-a6ab-367563f20686'

```

Version 4 (random):

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

```

Expand Down Expand Up @@ -67,6 +90,15 @@ uuidv1(); // -> v1 UUID
</script>
```

For version 3 uuids:

```html
<script src="http://wzrd.in/standalone/uuid%2Fv3@latest"></script>
<script>
uuidv3('http://example.com/hello', uuidv3.URL); // -> v3 UUID
</script>
```

For version 4 uuids:

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

* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
* `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
* `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.

* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
Expand Down Expand Up @@ -132,8 +164,43 @@ Example: In-place generation of two binary IDs
```javascript
// Generate two ids in an array
const arr = new Array();
uuidv1(null, arr, 0); // ⇨ [ 152, 81, 152, 208, 126, 79, 17, 231, 146, 52, 251, 113, 144, 200, 86, 228 ]
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 ]
uuidv1(null, arr, 0); // ⇨ [ 71, 30, 112, 176, 241, 163, 17, 231, 146, 52, 189, 91, 91, 160, 155, 31 ]
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 ]

```

### Version 3

```javascript
const uuidv3 = require('uuid/v3');

// Incantations
uuidv3(name, namespace);
uuidv3(name, namespace, buffer);
uuidv3(name, namespace, buffer, offset);
```

Generate and return a RFC4122 v3 UUID.

* `name` - (String | Array[]) "name" to create UUID with
* `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0

Returns `buffer`, if specified, otherwise the string form of the UUID

Example:

```javascript
// Generate a unique namespace (typically you would do this once, outside of
// your project, then bake this value into your code)
const uuidv4 = require('uuid/v4');
const uuidv3 = require('uuid/v3');
const MY_NAMESPACE = uuidv4(); // ⇨ '029f3419-d770-48bc-8862-5efd8eef925d'

// Generate a couple namespace uuids
uuidv3('hello', MY_NAMESPACE); // ⇨ 'be216b77-2b79-3713-99af-a0add9d751f2'
uuidv3('world', MY_NAMESPACE); // ⇨ '834a3f0c-30bd-35f7-a090-c718e1db7c56'

```

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

```javascript
const buffer = new Array();
uuidv4(null, buffer, 0); // ⇨ [ 217, 119, 223, 141, 202, 93, 66, 3, 178, 198, 149, 37, 232, 4, 107, 241 ]
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 ]
uuidv4(null, buffer, 0); // ⇨ [ 36, 127, 174, 168, 247, 125, 67, 114, 180, 253, 89, 117, 13, 63, 184, 208 ]
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 ]

```

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

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

```

Expand Down
18 changes: 9 additions & 9 deletions README_js.md
Expand Up @@ -23,14 +23,14 @@ Then generate your uuid version of choice ...

Version 1 (timestamp):

```javascript --context
```javascript --run uuid
const uuidv1 = require('uuid/v1');
uuidv1(); // RESULT
```

Version 3 (namespace):

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

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

Version 4 (random):

```javascript --context
```javascript --run uuid
const uuidv4 = require('uuid/v4');
uuidv4(); // RESULT
```

Version 5 (namespace):

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

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

* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
* `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
* `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.

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

Example: Generate string UUID with fully-specified options

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

Example: In-place generation of two binary IDs

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

Example: Generate string UUID with predefined `random` values

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

Example: Generate two IDs in a single buffer

```javascript --context
```javascript --run uuid
const buffer = new Array();
uuidv4(null, buffer, 0); // RESULT
uuidv4(null, buffer, 16); // RESULT
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"eslint": "4.5.0",
"mocha": "3.1.2",
"runmd": "0.1.7"
"runmd": "1.0.1"
},
"scripts": {
"test": "mocha test/test.js",
Expand Down

0 comments on commit 67d697c

Please sign in to comment.