Skip to content

Commit

Permalink
docs: move react-native docs to separate section (#387)
Browse files Browse the repository at this point in the history
* link to React Native readme section from rng error
* For linkability, move react-native docs to separate section.
* Link to readme in src/rng-browser.js

Co-Authored-By: Robert Kieffer <robert@broofa.com>
  • Loading branch information
ctavan and broofa authored Feb 28, 2020
1 parent 719e1b4 commit 84e6733
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
- Node 8, 10, 12
- Chrome, Safari, Firefox, Edge, IE 11 browsers
- Webpack and rollup.js module bundlers
- React Native ([see note](#getrandomvalues-not-supported))
- **Secure** - Cryptographically-strong random values
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
- **CLI** - Includes the [`uuid` command line](#command-line) utility
Expand All @@ -35,8 +36,6 @@ versions, all of which are supported here. In order of popularity, they are:

**Unsure which one to use?** Use version 4 (random) unless you have a specific need for one of the other versions. See also [this FAQ](https://github.com/tc39/proposal-uuid#faq).

**Are you using React Native?** If you are using this library from React Native, you need to add a polyfill for `crypto.getRandomValues`. We recommend using [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

### Create Version 4 (Random) UUIDs

```javascript
Expand Down Expand Up @@ -336,6 +335,16 @@ Available bundles:
- https://unpkg.com/uuid@latest/dist/umd/
- https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/

## "getRandomValues() not supported"

This error occurs in environments where the standard
[`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
API is not supported. This issue can be resolved by adding an appropriate polyfill:

| Environment | Suggested Polyfill |
| ------------ | --------------------------------------------------------------------------------------------------- |
| React Native | [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme) |

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
13 changes: 11 additions & 2 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
- Node 8, 10, 12
- Chrome, Safari, Firefox, Edge, IE 11 browsers
- Webpack and rollup.js module bundlers
- React Native ([see note](#getrandomvalues-not-supported))
- **Secure** - Cryptographically-strong random values
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
- **CLI** - Includes the [`uuid` command line](#command-line) utility
Expand All @@ -48,8 +49,6 @@ versions, all of which are supported here. In order of popularity, they are:

**Unsure which one to use?** Use version 4 (random) unless you have a specific need for one of the other versions. See also [this FAQ](https://github.com/tc39/proposal-uuid#faq).

**Are you using React Native?** If you are using this library from React Native, you need to add a polyfill for `crypto.getRandomValues`. We recommend using [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

### Create Version 4 (Random) UUIDs

```javascript --run v4
Expand Down Expand Up @@ -325,6 +324,16 @@ Available bundles:
- https://unpkg.com/uuid@latest/dist/umd/
- https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/

## "getRandomValues() not supported"

This error occurs in environments where the standard
[`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
API is not supported. This issue can be resolved by adding an appropriate polyfill:

| Environment | Suggested Polyfill |
| ------------ | --------------------------------------------------------------------------------------------------- |
| React Native | [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme) |

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
2 changes: 1 addition & 1 deletion src/rng-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
export default function rng() {
if (!getRandomValues) {
throw new Error(
'uuid: This browser does not seem to support crypto.getRandomValues(). If you need to support this browser, please provide a custom random number generator through options.rng.',
'crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported',
);
}
return getRandomValues(rnds8);
Expand Down

0 comments on commit 84e6733

Please sign in to comment.