Comparing version 1.0.7 to 1.1.0
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 1.1 | ||
* Add non-secure ID generator. | ||
* Suggest to use non-secure ID generator for React Native developers. | ||
* Reduce size. | ||
## 1.0.7 | ||
@@ -5,0 +10,0 @@ * Fix documentation. |
@@ -0,1 +1,10 @@ | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof self === 'undefined' || (!self.crypto && !self.msCrypto)) { | ||
throw new Error( | ||
'Your browser does not have secure random generator. ' + | ||
'If you don’t need unpredictable IDs, you can use nanoid/non-secure.' | ||
) | ||
} | ||
} | ||
var crypto = self.crypto || self.msCrypto | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "nanoid", | ||
"version": "1.0.7", | ||
"description": "A tiny (146 bytes), secure URL-friendly unique string ID generator", | ||
"version": "1.1.0", | ||
"description": "A tiny (143 bytes), secure URL-friendly unique string ID generator", | ||
"keywords": [ | ||
@@ -18,45 +18,3 @@ "uuid", | ||
}, | ||
"devDependencies": { | ||
"benchmark": "^2.1.4", | ||
"chalk": "^2.4.1", | ||
"docdash": "^0.4.0", | ||
"eslint": "^5.0.1", | ||
"eslint-ci": "^0.1.1", | ||
"eslint-config-logux": "^23.0.2", | ||
"eslint-config-standard": "^11.0.0", | ||
"eslint-plugin-es5": "^1.3.1", | ||
"eslint-plugin-import": "^2.13.0", | ||
"eslint-plugin-jest": "^21.17.0", | ||
"eslint-plugin-node": "^6.0.1", | ||
"eslint-plugin-promise": "^3.8.0", | ||
"eslint-plugin-security": "^1.4.0", | ||
"eslint-plugin-standard": "^3.1.0", | ||
"html-webpack-plugin": "^3.2.0", | ||
"jest": "^23.3.0", | ||
"jsdoc": "^3.5.5", | ||
"lint-staged": "^7.2.0", | ||
"microtime": "^2.1.8", | ||
"pre-commit": "^1.2.2", | ||
"rimraf": "^2.6.2", | ||
"shortid": "^2.2.9", | ||
"size-limit": "^0.18.3", | ||
"svgo": "^1.0.5", | ||
"uuid": "^3.3.2", | ||
"webpack": "^4.15.1", | ||
"webpack-cli": "^3.0.8", | ||
"webpack-dev-server": "^3.1.4", | ||
"yaspeller-ci": "^1.0.0" | ||
}, | ||
"scripts": { | ||
"lint-staged": "lint-staged", | ||
"spellcheck": "yarn docs && yaspeller-ci *.md docs/*.html", | ||
"clean": "rimraf docs/ coverage/", | ||
"docs": "jsdoc --configure .jsdocrc *.js", | ||
"lint": "eslint-ci *.js test/*.js", | ||
"test": "jest --coverage && yarn lint && size-limit && yarn spellcheck", | ||
"start": "webpack-dev-server --config test/demo/webpack.config" | ||
}, | ||
"pre-commit": [ | ||
"lint-staged" | ||
] | ||
"scripts": {} | ||
} |
@@ -6,12 +6,12 @@ # Nano ID | ||
A tiny, secure, URL-friendly, unique string ID generator for JavaScript. | ||
A tiny, secure, URL-friendly, unique string ID generator for JavaScript. | ||
**Safe.** It uses cryptographically strong random APIs | ||
and tests distribution of symbols. | ||
and tests distribution of symbols. | ||
**Small.** 146 bytes (minified and gzipped). No dependencies. | ||
It uses [Size Limit] to control size. | ||
**Small.** 143 bytes (minified and gzipped). No dependencies. | ||
It uses [Size Limit] to control size. | ||
**Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_~`). | ||
As result it could reduce ID size from 36 to 21 symbols. | ||
**Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_~`). | ||
As result it could reduce ID size from 36 to 21 symbols. | ||
@@ -23,3 +23,3 @@ ```js | ||
The generator supports Node.js and [all browsers] starting from IE 11. | ||
The generator supports Node.js, React Native, and [all browsers]. | ||
@@ -55,3 +55,3 @@ [all browsers]: http://caniuse.com/#feat=getrandomvalues | ||
Nano ID uses a [better algorithm] and is tested for uniformity: | ||
Nano ID uses a [better algorithm] and is tested for uniformity. | ||
@@ -79,3 +79,3 @@ <img src="img/distribution.png" alt="Nano ID uniformity" | ||
2. Nano ID code is 3 times less than `uuid/v4` package: | ||
146 bytes instead of 435. | ||
143 bytes instead of 435. | ||
@@ -86,7 +86,8 @@ | ||
``` | ||
$ ./benchmark | ||
nanoid 332,991 ops/sec | ||
nanoid/generate 326,636 ops/sec | ||
uuid/v4 315,344 ops/sec | ||
shortid 33,717 ops/sec | ||
$ ./test/benchmark | ||
nanoid 353,737 ops/sec | ||
nanoid/non-secure 2,043,665 ops/sec | ||
nanoid/generate 348,442 ops/sec | ||
uuid/v4 350,075 ops/sec | ||
shortid 85,107 ops/sec | ||
``` | ||
@@ -111,3 +112,3 @@ | ||
If you want to reduce ID length (and increase collisions probability), | ||
you can pass the length as an argument: | ||
you can pass the length as an argument. | ||
@@ -124,2 +125,18 @@ ```js | ||
### React Native and Web Workers | ||
React Native and Web Worker don’t have access to secure random generator. | ||
Security is important in ID, when ID should be unpredictable. For instance, | ||
in “access by URL” link generation. | ||
If you don’t need unpredictable IDs, but you need React Native | ||
or Web Workers support, you can use non‑secure ID generator. | ||
```js | ||
var nanoid = require('nanoid/non-secure') | ||
model.id = nanoid() //=> "Uakgb_J5m9g~0JDMbcJqLJ" | ||
``` | ||
### Custom Alphabet or Length | ||
@@ -137,2 +154,3 @@ | ||
in our [ID collision probability] calculator. | ||
You can find popular alphabets in [`nanoid-dictionary`]. | ||
@@ -142,4 +160,2 @@ Alphabet must contain 256 symbols or less. | ||
You can find popular alphabets in [`nanoid-dictionary`]. | ||
[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/ | ||
@@ -170,3 +186,3 @@ [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary | ||
If you want to use the same URL-friendly symbols with `format`, | ||
you can get the default alphabet from the `url` module: | ||
you can get the default alphabet from the `url` file. | ||
@@ -173,0 +189,0 @@ ```js |
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
12764
0
12
152
215