Comparing version 2.0.4 to 2.1.0
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 2.1 | ||
* Improve React Native support (by Sebastian Werner). | ||
## 2.0.4 | ||
@@ -5,0 +8,0 @@ * Improve error text for React Native (by Sebastian Werner). |
@@ -6,3 +6,3 @@ if (process.env.NODE_ENV !== 'production') { | ||
'If you don’t need unpredictable IDs, you can use `nanoid/non-secure`. ' + | ||
'If you need secure ID, see https://github.com/ai/nanoid/#react-native.' | ||
'For secure ID install `expo-random` locally and use `nanoid/async`.' | ||
) | ||
@@ -9,0 +9,0 @@ } |
{ | ||
"name": "nanoid", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "A tiny (141 bytes), secure URL-friendly unique string ID generator", | ||
@@ -20,10 +20,12 @@ "keywords": [ | ||
}, | ||
"react-native": { | ||
"./async/random.js": "./random.rn.js" | ||
}, | ||
"sideEffects": false, | ||
"eslintIgnore": [ | ||
"node_modules", | ||
"test/demo/build" | ||
], | ||
"sharec": { | ||
"version": "0.4.1" | ||
"version": "0.4.2" | ||
} | ||
} |
@@ -9,8 +9,8 @@ # Nano ID | ||
* **Small.** 141 bytes (minified and gzipped). No dependencies. | ||
[Size Limit] controls the size. | ||
* **Safe.** It uses cryptographically strong random APIs | ||
and tests distribution of symbols. | ||
[Size Limit] controls the size. | ||
* **Safe.** It uses cryptographically strong random APIs. | ||
Can be used in clusters. | ||
* **Fast.** It’s 16% faster than UUID. | ||
* **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`). | ||
So ID size was reduced from 36 to 21 symbols. | ||
So ID size was reduced from 36 to 21 symbols. | ||
@@ -22,3 +22,3 @@ ```js | ||
The generator supports Node.js, React Native, and [all browsers]. | ||
Supports [all browsers], Node.js and React Native. | ||
@@ -190,20 +190,16 @@ [all browsers]: http://caniuse.com/#feat=getrandomvalues | ||
To generate secure random IDs in React Native, you must use a native random | ||
generator (like [`expo-random`] or [`react-native-securerandom`]) and the | ||
asynchronous API: | ||
React Native doesn’t have built-in random generator. | ||
1. Check [`expo-random`] docs and install it. | ||
2. Use `nanoid/async` instead of synchronous `nanoid`. | ||
```js | ||
const getRandomBytesAsync = require('expo-random').getRandomBytesAsync | ||
const format = require('nanoid/async/format') | ||
const url = require('nanoid/url') | ||
const nanoid = require('nanoid/async') | ||
async function createUser () { | ||
user.id = await format(getRandomBytesAsync, url, 21); | ||
user.id = await nanoid() | ||
} | ||
``` | ||
[`expo-random`]: https://github.com/expo/expo/tree/master/packages/expo-random | ||
[`react-native-securerandom`]: https://github.com/rh389/react-native-securerandom | ||
### PouchDB and CouchDB | ||
@@ -210,0 +206,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24511
20
384
380