Comparing version 1.3.4 to 2.0.0
var crypto = self.crypto || self.msCrypto | ||
/* | ||
* This alphabet uses a-z A-Z 0-9 _~ symbols. | ||
* This alphabet uses a-z A-Z 0-9 _- symbols. | ||
* Symbols order was changed for better gzip compression. | ||
*/ | ||
var url = 'ModuleSymbhasOwnPr0123456789ABCDEFGHIJKLNQRTUVWXYZ_cfgijkpqtvxz~' | ||
var url = 'Uint8ArModuleSymbhasOw-012345679BCDEFGHIJKLNPQRTVWXYZ_cfgjkpqvxz' | ||
@@ -9,0 +9,0 @@ module.exports = function (size) { |
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 2.0 | ||
* Use `-` instead of `~` in default alphabet to by file name safe. | ||
* Add `nanoid/non-secure/generate`. | ||
## 1.3.4 | ||
@@ -5,0 +9,0 @@ * Reduce `non-secure` size. |
@@ -13,6 +13,6 @@ if (process.env.NODE_ENV !== 'production') { | ||
/* | ||
* This alphabet uses a-z A-Z 0-9 _~ symbols. | ||
* This alphabet uses a-z A-Z 0-9 _- symbols. | ||
* Symbols order was changed for better gzip compression. | ||
*/ | ||
var url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz~' | ||
var url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-' | ||
@@ -19,0 +19,0 @@ module.exports = function (size) { |
@@ -16,3 +16,3 @@ var random = require('./random') | ||
* const nanoid = require('nanoid') | ||
* model.id = nanoid() //=> "Uakgb_J5m9g~0JDMbcJqL" | ||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL" | ||
* | ||
@@ -19,0 +19,0 @@ * @name nanoid |
{ | ||
"name": "nanoid", | ||
"version": "1.3.4", | ||
"description": "A tiny (143 bytes), secure URL-friendly unique string ID generator", | ||
"version": "2.0.0", | ||
"description": "A tiny (141 bytes), secure URL-friendly unique string ID generator", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "uuid", |
@@ -8,3 +8,3 @@ # Nano ID | ||
* **Small.** 142 bytes (minified and gzipped). No dependencies. | ||
* **Small.** 141 bytes (minified and gzipped). No dependencies. | ||
It uses [Size Limit] to control size. | ||
@@ -14,3 +14,3 @@ * **Safe.** It uses cryptographically strong random APIs | ||
* **Fast.** It’s 16% faster than UUID. | ||
* **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_~`). | ||
* **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`). | ||
So ID size was reduced from 36 to 21 symbols. | ||
@@ -20,3 +20,3 @@ | ||
var nanoid = require('nanoid') | ||
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B~myT" | ||
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT" | ||
``` | ||
@@ -78,3 +78,3 @@ | ||
2. Nano ID code is 3 times less than `uuid/v4` package: | ||
142 bytes instead of 435. | ||
141 bytes instead of 435. | ||
@@ -107,3 +107,3 @@ | ||
The main module uses URL-friendly symbols (`A-Za-z0-9_~`) and returns an ID | ||
The main module uses URL-friendly symbols (`A-Za-z0-9_-`) and returns an ID | ||
with 21 characters (to have a collision probability similar to UUID v4). | ||
@@ -113,3 +113,3 @@ | ||
const nanoid = require('nanoid') | ||
model.id = nanoid() //=> "Uakgb_J5m9g~0JDMbcJqLJ" | ||
model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ" | ||
``` | ||
@@ -124,3 +124,3 @@ | ||
```js | ||
nanoid(10) //=> "IRFa~VaY2b" | ||
nanoid(10) //=> "IRFa-VaY2b" | ||
``` | ||
@@ -164,3 +164,3 @@ | ||
const nanoid = require('nanoid/non-secure') | ||
model.id = nanoid() //=> "Uakgb_J5m9g~0JDMbcJqLJ" | ||
model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ" | ||
``` | ||
@@ -206,3 +206,3 @@ | ||
Asynchronous API is also available: | ||
Asynchronous and non-secure API is also available: | ||
@@ -216,2 +216,8 @@ ```js | ||
```js | ||
const generate = require('nanoid/non-secure/generate') | ||
user.id = generate('1234567890abcdef', 10) | ||
``` | ||
[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/ | ||
@@ -218,0 +224,0 @@ [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary |
/** | ||
* URL safe symbols. | ||
* | ||
* This alphabet uses a-z A-Z 0-9 _~ symbols. | ||
* This alphabet uses a-z A-Z 0-9 _- symbols. | ||
* Symbols order was changed for better gzip compression. | ||
@@ -15,2 +15,2 @@ * | ||
module.exports = | ||
'SymboljecthasOwnPr0123456789ABCDEFGHIJKLMNQRTUVWXYZ_dfgikpquvxz~' | ||
'ModuleSymbhasOwnPr-0123456789ABCDEFGHIJKLNQRTUVWXYZ_cfgijkpqtvxz' |
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
22818
19
408
296