Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish v3.2.0 #240

Merged
merged 10 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
.idea/**
.DS_Store
node_modules
package-lock.json
107 changes: 73 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<!--
-- 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))

[**Deprecation warning**: The use of `require('uuid')` is deprecated and will not be
supported after version 3.x of this module. Instead, use `require('uuid/[v1|v3|v4|v5]')` as shown in the examples below.]

## Quickstart - CommonJS (Recommended)

```shell
Expand All @@ -22,15 +28,35 @@ Version 1 (timestamp):

```javascript
const uuidv1 = require('uuid/v1');
uuidv1(); // ⇨ '985123a0-7e4f-11e7-9022-fb7190c856e4'
uuidv1(); // ⇨ '37c611a0-d44c-11e7-87f5-fda56f410c05'

```

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(); // ⇨ '85af1f4e-1ba1-4069-b5ea-a7319cd467b1'

```

Expand Down Expand Up @@ -67,6 +93,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 @@ -132,8 +167,35 @@ 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); // ⇨ [ 55, 206, 118, 16, 212, 76, 17, 231, 146, 52, 253, 165, 111, 65, 12, 5 ]
uuidv1(null, arr, 16); // ⇨ [ 55, 206, 118, 16, 212, 76, 17, 231, 146, 52, 253, 165, 111, 65, 12, 5, 55, 206, 196, 48, 212, 76, 17, 231, 146, 52, 253, 165, 111, 65, 12, 5 ]

```

### 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
uuidv3('hello world', MY_NAMESPACE); // ⇨ '042ffd34-d989-321c-ad06-f60826172424'

```

Expand Down Expand Up @@ -175,8 +237,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); // ⇨ [ 17, 199, 69, 178, 66, 14, 76, 246, 177, 55, 64, 173, 168, 143, 6, 92 ]
uuidv4(null, buffer, 16); // ⇨ [ 17, 199, 69, 178, 66, 14, 76, 246, 177, 55, 64, 173, 168, 143, 6, 92, 186, 164, 72, 251, 46, 2, 64, 166, 138, 136, 122, 35, 252, 28, 58, 60 ]

```

Expand All @@ -203,15 +265,7 @@ 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 uuidv5 = require('uuid/v5');
const MY_NAMESPACE = uuidv4(); // ⇨ '8dc079dd-0313-4563-864f-008eb45bf87f'

// 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 world', MY_NAMESPACE); // ⇨ '9f282611-e0fd-5650-8953-89c8e342da0b'

```

Expand All @@ -222,6 +276,9 @@ UUIDs can be generated from the command line with the `uuid` command.
```shell
$ uuid
ddeb27fb-d9a0-4624-be4d-4615062daed4

$ uuid v1
02d37060-d446-11e7-a9fa-7bdae751ebe1
```

Type `uuid --help` for usage details
Expand All @@ -232,23 +289,5 @@ Type `uuid --help` for usage details
npm test
```

## Deprecated API

The API below is available for legacy purposes and is not expected to be available post-3.X

```javascript
const uuid = require('uuid');

uuid.v1(...); // alias of uuid/v1
uuid.v4(...); // alias of uuid/v4
uuid(...); // alias of uuid/v4

// uuid.v5() is not supported in this API
```

## Legacy node-uuid package

The code for the legacy node-uuid package is available in the `node-uuid` branch.

----
Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
64 changes: 18 additions & 46 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Features:
* Uses cryptographically-strong random number APIs (when available)
* Zero-dependency, small footprint (... but not [this small](https://gist.github.com/982883))

[**Deprecation warning**: The use of `require('uuid')` is deprecated and will not be
supported after version 3.x of this module. Instead, use `require('uuid/[v1|v3|v4|v5]')` as shown in the examples below.]

## Quickstart - CommonJS (Recommended)

```shell
Expand All @@ -23,14 +26,14 @@ Then generate your uuid version of choice ...

Version 1 (timestamp):

```javascript --context
```javascript --run v1
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 +52,14 @@ uuidv3('Hello, World!', MY_NAMESPACE); // RESULT

Version 4 (random):

```javascript --context
```javascript --run v4
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 @@ -144,7 +147,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 v1
const v1options = {
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
clockseq: 0x1234,
Expand All @@ -156,7 +159,7 @@ uuidv1(v1options); // RESULT

Example: In-place generation of two binary IDs

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

Example:

```javascript --run
// 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(); // RESULT

// Generate a couple namespace uuids
uuidv3('hello', MY_NAMESPACE); // RESULT
uuidv3('world', MY_NAMESPACE); // RESULT
```javascript --run v3
uuidv3('hello world', MY_NAMESPACE); // RESULT
```

### Version 4
Expand All @@ -220,7 +215,7 @@ Returns `buffer`, if specified, otherwise the string form of the UUID

Example: Generate string UUID with predefined `random` values

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

Example: Generate two IDs in a single buffer

```javascript --context
```javascript --run v4
const buffer = new Array();
uuidv4(null, buffer, 0); // RESULT
uuidv4(null, buffer, 16); // RESULT
Expand Down Expand Up @@ -260,16 +255,8 @@ Returns `buffer`, if specified, otherwise the string form of the UUID

Example:

```javascript --run
// 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 uuidv5 = require('uuid/v5');
const MY_NAMESPACE = uuidv4(); // RESULT

// Generate a couple namespace uuids
uuidv5('hello', MY_NAMESPACE); // RESULT
uuidv5('world', MY_NAMESPACE); // RESULT
```javascript --run v5
uuidv5('hello world', MY_NAMESPACE); // RESULT
```

## Command Line
Expand All @@ -279,6 +266,9 @@ UUIDs can be generated from the command line with the `uuid` command.
```shell
$ uuid
ddeb27fb-d9a0-4624-be4d-4615062daed4

$ uuid v1
02d37060-d446-11e7-a9fa-7bdae751ebe1
```

Type `uuid --help` for usage details
Expand All @@ -288,21 +278,3 @@ Type `uuid --help` for usage details
```shell
npm test
```

## Deprecated API

The API below is available for legacy purposes and is not expected to be available post-3.X

```javascript
const uuid = require('uuid');

uuid.v1(...); // alias of uuid/v1
uuid.v4(...); // alias of uuid/v4
uuid(...); // alias of uuid/v4

// uuid.v5() is not supported in this API
```

## Legacy node-uuid package

The code for the legacy node-uuid package is available in the `node-uuid` branch.
Loading