Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
fix typo in wzrd url
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Nov 21, 2016
2 parents 813b02e + 1867c30 commit ad9bf1a
Show file tree
Hide file tree
Showing 20 changed files with 303 additions and 1,121 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
node_modules
.DS_Store
.nyc_output
coverage
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "4"
- "6"
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Robert Kieffer <[email protected]>
Christoph Tavan <[email protected]>
AJ ONeal <[email protected]>
Vincent Voyer <[email protected]>
Roman Shtylman <[email protected]>
24 changes: 24 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 3.0.0 (2016-11-17)

* remove .parse and .unparse

# 2.0.0

* Removed uuid.BufferClass

# 1.4.0

* Improved module context detection
* Removed public RNG functions

# 1.3.2

* Improve tests and handling of v1() options (Issue #24)
* Expose RNG option to allow for perf testing with different generators

# 1.3.0

* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
* Support for node.js crypto API
* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2010-2012 Robert Kieffer
Copyright (c) 2010-2016 Robert Kieffer and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
182 changes: 27 additions & 155 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,46 @@
# node-uuid
# 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:

* Generate RFC4122 version 1 or version 4 UUIDs
* Runs in node.js and all browsers.
* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid').
* Cryptographically strong random # generation
* `crypto.randomBytes(n)` in node.js
* `window.crypto.getRandomValues(ta)` in [supported browsers](https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues#Browser_Compatibility)
* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )
* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)
* Comes with a Command Line Interface for generating uuids on the command line
* Runs in node.js and browsers
* Cryptographically strong random number generation on supporting platforms
* Small footprint (Want something smaller? [Check this out](https://gist.github.com/982883) out!)

## Getting Started

Install it in your browser:

```html
<script src="uuid.js"></script>
```

Or in node.js:
## Quickstart - nodejs

```
npm install node-uuid
```shell
npm install uuid
```

```javascript
var uuid = require('node-uuid');
```
const uuid = require('uuid');

Then create some ids ...
// Generate a v4 (random) id
uuid() // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

```javascript
// Generate a v1 (time-based) id
uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
```

// Generate a v4 (random) id
uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
## Quickstart - browser

** Not recommende for production or even semi-production use. Use a bundling tool instead (i.e. webpack, browserify, rollup, etc)**

[wzrd.in](https://github.com/jfhbrook/wzrd.in) will serve up any npm module after performing basic bundling and minification.

```html
<script src="http://wzrd.in/standalone/uuid@latest"></script>
```

## API

### uuid(...)

Generate a V4 uuid. See uuid.v4 documentation below.

### uuid.v1([`options` [, `buffer` [, `offset`]]])

Generate and return a RFC4122 v1 (timestamp-based) UUID.
Expand Down Expand Up @@ -79,13 +76,9 @@ Example: In-place generation of two binary IDs

```javascript
// Generate two ids in an array
var arr = new Array(32); // -> []
const arr = new Array(32); // -> []
uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
uuid.v1(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]

// Optionally use uuid.unparse() to get stringify the ids
uuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115'
uuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115'
```

### uuid.v4([`options` [, `buffer` [, `offset`]]])
Expand Down Expand Up @@ -117,138 +110,17 @@ uuid.v4({
Example: Generate two IDs in a single buffer

```javascript
var buffer = new Array(32); // (or 'new Buffer' in node.js)
const buffer = new Array(32); // (or 'new Buffer' in node.js)
uuid.v4(null, buffer, 0);
uuid.v4(null, buffer, 16);
```

### uuid.parse(id[, buffer[, offset]])
### uuid.unparse(buffer[, offset])

Parse and unparse UUIDs

* `id` - (String) UUID(-like) string
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0

Example parsing and unparsing a UUID string

```javascript
var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>
var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'
```

### uuid.noConflict()

(Browsers only) Set `uuid` property back to it's previous value.

Returns the node-uuid object.

Example:

```javascript
var myUuid = uuid.noConflict();
myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
```

## Deprecated APIs

Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.

### uuid([format [, buffer [, offset]]])

uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).

### uuid.BufferClass

The class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API.

## Command Line Interface

To use the executable, it's probably best to install this library globally.

`npm install -g node-uuid`

Usage:

```
USAGE: uuid [version] [options]
options:
--help Display this message and exit
```

`version` must be an RFC4122 version that is supported by this library, which is currently version 1 and version 4 (denoted by "v1" and "v4", respectively). `version` defaults to version 4 when not supplied.

### Examples

```
> uuid
3a91f950-dec8-4688-ba14-5b7bbfc7a563
```

```
> uuid v1
9d0b43e0-7696-11e3-964b-250efa37a98e
```

```
> uuid v4
6790ac7c-24ac-4f98-8464-42f6d98a53ae
```

## Testing

In node.js

```
npm test
```

In Browser

```
open test/test.html
```

### Benchmarking

Requires node.js

```
npm install uuid uuid-js
node benchmark/benchmark.js
```

For a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)

For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).

## Release notes

### 1.4.6

* Properly detect node crypto and whatwg crypto
* Workaround phantomjs/browserify bug
* Explicit check for `window` rather implicit this-global
* Issue warning if Math.random() is being used
* "use strict";
* A few jshint / stylistic updates (=== and such)

### 1.4.0

* Improved module context detection
* Removed public RNG functions

### 1.3.2

* Improve tests and handling of v1() options (Issue #24)
* Expose RNG option to allow for perf testing with different generators

### 1.3.0
## Legacy node-uuid package

* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
* Support for node.js crypto API
* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
The code for the legacy node-uuid package is available in the `node-uuid` branch.
53 changes: 0 additions & 53 deletions benchmark/README.md

This file was deleted.

Loading

0 comments on commit ad9bf1a

Please sign in to comment.