nanoid 3.1.18 → 3.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nanoid might be problematic. Click here for more details.
- package/README.md +51 -37
- package/async/index.browser.js +1 -2
- package/async/index.cjs +1 -2
- package/async/index.d.ts +3 -3
- package/async/index.js +1 -2
- package/async/index.native.js +1 -2
- package/index.browser.js +2 -4
- package/index.cjs +3 -4
- package/index.d.ts +5 -5
- package/index.dev.js +2 -4
- package/index.js +3 -4
- package/index.prod.js +2 -4
- package/non-secure/index.d.ts +2 -2
- package/package.json +10 -5
- package/CHANGELOG.md +0 -235
package/README.md
CHANGED
@@ -47,7 +47,6 @@ Supports modern browsers, IE [with Babel], Node.js and React Native.
|
|
47
47
|
* [Create React App](#create-react-app)
|
48
48
|
* [React Native](#react-native)
|
49
49
|
* [Rollup](#rollup)
|
50
|
-
* [Expo](#expo)
|
51
50
|
* [PouchDB and CouchDB](#pouchdb-and-couchdb)
|
52
51
|
* [Mongoose](#mongoose)
|
53
52
|
* [ES Modules](#es-modules)
|
@@ -74,9 +73,9 @@ There are three main differences between Nano ID and UUID v4:
|
|
74
73
|
|
75
74
|
1. Nano ID uses a bigger alphabet, so a similar number of random bits
|
76
75
|
are packed in just 21 symbols instead of 36.
|
77
|
-
2. Nano ID code is
|
78
|
-
108 bytes instead of
|
79
|
-
3. Because of memory allocation tricks, Nano ID is
|
76
|
+
2. Nano ID code is **4.5 times less** than `uuid/v4` package:
|
77
|
+
108 bytes instead of 483.
|
78
|
+
3. Because of memory allocation tricks, Nano ID is **60%** faster than UUID.
|
80
79
|
|
81
80
|
|
82
81
|
## Benchmark
|
@@ -85,8 +84,8 @@ There are three main differences between Nano ID and UUID v4:
|
|
85
84
|
$ node ./test/benchmark.js
|
86
85
|
nanoid 2,280,683 ops/sec
|
87
86
|
customAlphabet 1,851,117 ops/sec
|
88
|
-
uid.sync 313,306 ops/sec
|
89
87
|
uuid v4 1,348,425 ops/sec
|
88
|
+
uid.sync 313,306 ops/sec
|
90
89
|
secure-random-string 294,161 ops/sec
|
91
90
|
cuid 158,988 ops/sec
|
92
91
|
shortid 37,222 ops/sec
|
@@ -139,7 +138,7 @@ Test configuration: Dell XPS 2-in-1 7390, Fedora 32, Node.js 15.1.
|
|
139
138
|
Tidelift will coordinate the fix and disclosure.
|
140
139
|
|
141
140
|
[Secure random values (in Node.js)]: https://gist.github.com/joepie91/7105003c3b26e65efcea63f3db82dfba
|
142
|
-
[better algorithm]: https://github.com/ai/nanoid/blob/
|
141
|
+
[better algorithm]: https://github.com/ai/nanoid/blob/main/index.js
|
143
142
|
|
144
143
|
|
145
144
|
## Usage
|
@@ -154,6 +153,12 @@ import { nanoid } from 'nanoid'
|
|
154
153
|
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
|
155
154
|
```
|
156
155
|
|
156
|
+
In Node.js you can use CommonJS import:
|
157
|
+
|
158
|
+
```js
|
159
|
+
const { nanoid } = require('nanoid')
|
160
|
+
```
|
161
|
+
|
157
162
|
If you want to reduce the ID size (and increase collisions probability),
|
158
163
|
you can pass the size as an argument.
|
159
164
|
|
@@ -192,22 +197,43 @@ import { nanoid } from 'nanoid'
|
|
192
197
|
|
193
198
|
### React
|
194
199
|
|
195
|
-
|
196
|
-
among renders.
|
200
|
+
There’s currently no correct way to use nanoid for React `key` prop
|
201
|
+
since it should be consistent among renders.
|
197
202
|
|
198
|
-
|
203
|
+
```jsx
|
204
|
+
function Todos({todos}) {
|
205
|
+
return (
|
206
|
+
<ul>
|
207
|
+
{todos.map(todo => (
|
208
|
+
<li key={nanoid()}> /* DON’T DO IT */
|
209
|
+
{todo.text}
|
210
|
+
</li>
|
211
|
+
))}
|
212
|
+
</ul>
|
213
|
+
)
|
214
|
+
}
|
215
|
+
```
|
216
|
+
|
217
|
+
You should rather try to reach for stable id inside your list item.
|
199
218
|
|
200
219
|
```jsx
|
201
|
-
|
220
|
+
const todoItems = todos.map((todo) =>
|
221
|
+
<li key={todo.id}>
|
222
|
+
{todo.text}
|
223
|
+
</li>
|
224
|
+
)
|
202
225
|
```
|
203
226
|
|
204
|
-
|
227
|
+
In case you don’t have stable ids you'd rather use index as `key`
|
228
|
+
instead of `nanoid()`:
|
205
229
|
|
206
230
|
```jsx
|
207
|
-
const
|
208
|
-
|
209
|
-
|
210
|
-
}
|
231
|
+
const todoItems = todos.map((text, index) =>
|
232
|
+
<li key={index}> /* Still not recommended but preferred over nanoid().
|
233
|
+
Only do this if items have no stable IDs. */
|
234
|
+
{text}
|
235
|
+
</li>
|
236
|
+
)
|
211
237
|
```
|
212
238
|
|
213
239
|
If you want to use Nano ID in the `id` prop, you must set some string prefix
|
@@ -235,7 +261,8 @@ Use Nano ID 2 `npm i nanoid@^2.0.0` until Create React App 4.0 release.
|
|
235
261
|
|
236
262
|
### React Native
|
237
263
|
|
238
|
-
React Native does not have built-in random generator.
|
264
|
+
React Native does not have built-in random generator. The following polyfill
|
265
|
+
works for plain React Native and Expo starting with `39.x`.
|
239
266
|
|
240
267
|
1. Check [`react-native-get-random-values`] docs and install it.
|
241
268
|
2. Import it before Nano ID.
|
@@ -252,39 +279,25 @@ For Expo framework see the next section.
|
|
252
279
|
|
253
280
|
### Rollup
|
254
281
|
|
255
|
-
For Rollup you will need [`@rollup/plugin-
|
282
|
+
For Rollup you will need [`@rollup/plugin-node-resolve`] to bundle browser version
|
283
|
+
of this library and [`@rollup/plugin-replace`] to replace
|
256
284
|
`process.env.NODE_ENV`:
|
257
285
|
|
258
286
|
```js
|
259
287
|
plugins: [
|
288
|
+
nodeResolve({
|
289
|
+
browser: true
|
290
|
+
}),
|
260
291
|
replace({
|
261
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.
|
292
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
262
293
|
})
|
263
294
|
]
|
264
295
|
```
|
265
296
|
|
297
|
+
[`@rollup/plugin-node-resolve`]: https://github.com/rollup/plugins/tree/master/packages/node-resolve
|
266
298
|
[`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace
|
267
299
|
|
268
300
|
|
269
|
-
### Expo
|
270
|
-
|
271
|
-
If you use Expo in React Native, you need a different workaround.
|
272
|
-
|
273
|
-
1. Install [`expo-random`](https://www.npmjs.com/package/expo-random).
|
274
|
-
2. Use `nanoid/async` instead of `nanoid`.
|
275
|
-
3. Import `index.native.js` file directly.
|
276
|
-
|
277
|
-
```js
|
278
|
-
import { nanoid } from 'nanoid/async/index.native'
|
279
|
-
|
280
|
-
async function createUser () {
|
281
|
-
user.id = await nanoid()
|
282
|
-
}
|
283
|
-
```
|
284
|
-
|
285
|
-
[`expo-random`]: https://www.npmjs.com/package/expo-random
|
286
|
-
|
287
|
-
|
288
301
|
### PouchDB and CouchDB
|
289
302
|
|
290
303
|
In PouchDB and CouchDB, IDs can’t start with an underscore `_`.
|
@@ -383,6 +396,7 @@ the same ID generator on the client and server side.
|
|
383
396
|
* [Janet](https://sr.ht/~statianzo/janet-nanoid/)
|
384
397
|
* [Java](https://github.com/aventrix/jnanoid)
|
385
398
|
* [Nim](https://github.com/icyphox/nanoid.nim)
|
399
|
+
* [Perl](https://github.com/tkzwtks/Nanoid-perl)
|
386
400
|
* [PHP](https://github.com/hidehalo/nanoid-php)
|
387
401
|
* [Python](https://github.com/puyuan/py-nanoid)
|
388
402
|
with [dictionaries](https://pypi.org/project/nanoid-dictionary)
|
package/async/index.browser.js
CHANGED
@@ -34,8 +34,7 @@ let customAlphabet = (alphabet, size) => {
|
|
34
34
|
while (i--) {
|
35
35
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
36
36
|
id += alphabet[bytes[i] & mask] || ''
|
37
|
-
|
38
|
-
if (id.length === +size) return Promise.resolve(id)
|
37
|
+
if (id.length === size) return Promise.resolve(id)
|
39
38
|
}
|
40
39
|
}
|
41
40
|
}
|
package/async/index.cjs
CHANGED
@@ -45,8 +45,7 @@ let customAlphabet = (alphabet, size) => {
|
|
45
45
|
while (i--) {
|
46
46
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
47
47
|
id += alphabet[bytes[i] & mask] || ''
|
48
|
-
|
49
|
-
if (id.length === +size) return id
|
48
|
+
if (id.length === size) return id
|
50
49
|
}
|
51
50
|
return tick(id)
|
52
51
|
})
|
package/async/index.d.ts
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
* @param size Size of the ID. The default size is 21.
|
15
15
|
* @returns A promise with a random string.
|
16
16
|
*/
|
17
|
-
export function nanoid
|
17
|
+
export function nanoid(size?: number): Promise<string>
|
18
18
|
|
19
19
|
/**
|
20
20
|
* A low-level function.
|
@@ -35,7 +35,7 @@ export function nanoid (size?: number): Promise<string>
|
|
35
35
|
* })
|
36
36
|
* ```
|
37
37
|
*/
|
38
|
-
export function customAlphabet
|
38
|
+
export function customAlphabet(
|
39
39
|
alphabet: string,
|
40
40
|
size: number
|
41
41
|
): () => Promise<string>
|
@@ -53,4 +53,4 @@ export function customAlphabet (
|
|
53
53
|
* @param bytes Size of the array.
|
54
54
|
* @returns A promise with a random bytes array.
|
55
55
|
*/
|
56
|
-
export function random
|
56
|
+
export function random(bytes: number): Promise<Uint8Array>
|
package/async/index.js
CHANGED
@@ -45,8 +45,7 @@ let customAlphabet = (alphabet, size) => {
|
|
45
45
|
while (i--) {
|
46
46
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
47
47
|
id += alphabet[bytes[i] & mask] || ''
|
48
|
-
|
49
|
-
if (id.length === +size) return id
|
48
|
+
if (id.length === size) return id
|
50
49
|
}
|
51
50
|
return tick(id)
|
52
51
|
})
|
package/async/index.native.js
CHANGED
@@ -31,8 +31,7 @@ let customAlphabet = (alphabet, size) => {
|
|
31
31
|
while (i--) {
|
32
32
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
33
33
|
id += alphabet[bytes[i] & mask] || ''
|
34
|
-
|
35
|
-
if (id.length === +size) return id
|
34
|
+
if (id.length === size) return id
|
36
35
|
}
|
37
36
|
return tick(id)
|
38
37
|
})
|
package/index.browser.js
CHANGED
@@ -14,8 +14,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
14
14
|
'React Native does not have a built-in secure random generator. ' +
|
15
15
|
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
|
16
16
|
'For secure IDs, import `react-native-get-random-values` ' +
|
17
|
-
'before Nano ID.
|
18
|
-
'and use `nanoid/async`.'
|
17
|
+
'before Nano ID.'
|
19
18
|
)
|
20
19
|
}
|
21
20
|
if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
|
@@ -67,8 +66,7 @@ let customRandom = (alphabet, size, getRandom) => {
|
|
67
66
|
while (j--) {
|
68
67
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
69
68
|
id += alphabet[bytes[j] & mask] || ''
|
70
|
-
|
71
|
-
if (id.length === +size) return id
|
69
|
+
if (id.length === size) return id
|
72
70
|
}
|
73
71
|
}
|
74
72
|
}
|
package/index.cjs
CHANGED
@@ -49,13 +49,12 @@ let customRandom = (alphabet, size, getRandom) => {
|
|
49
49
|
let id = ''
|
50
50
|
while (true) {
|
51
51
|
let bytes = getRandom(step)
|
52
|
-
// A compact alternative for `for (
|
52
|
+
// A compact alternative for `for (let i = 0; i < step; i++)`.
|
53
53
|
let i = step
|
54
54
|
while (i--) {
|
55
55
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
56
56
|
id += alphabet[bytes[i] & mask] || ''
|
57
|
-
|
58
|
-
if (id.length === +size) return id
|
57
|
+
if (id.length === size) return id
|
59
58
|
}
|
60
59
|
}
|
61
60
|
}
|
@@ -66,7 +65,7 @@ let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)
|
|
66
65
|
let nanoid = (size = 21) => {
|
67
66
|
let bytes = random(size)
|
68
67
|
let id = ''
|
69
|
-
// A compact alternative for `for (
|
68
|
+
// A compact alternative for `for (let i = 0; i < size; i++)`.
|
70
69
|
while (size--) {
|
71
70
|
// It is incorrect to use bytes exceeding the alphabet size.
|
72
71
|
// The following mask reduces the random byte in the 0-255 value
|
package/index.d.ts
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
* @param size Size of the ID. The default size is 21.
|
13
13
|
* @returns A random string.
|
14
14
|
*/
|
15
|
-
export function nanoid
|
15
|
+
export function nanoid(size?: number): string
|
16
16
|
|
17
17
|
/**
|
18
18
|
* Generate secure unique ID with custom alphabet.
|
@@ -30,7 +30,7 @@ export function nanoid (size?: number): string
|
|
30
30
|
* nanoid() //=> "8ё56а"
|
31
31
|
* ```
|
32
32
|
*/
|
33
|
-
export function customAlphabet
|
33
|
+
export function customAlphabet(alphabet: string, size: number): () => string
|
34
34
|
|
35
35
|
/**
|
36
36
|
* Generate unique ID with custom random generator and alphabet.
|
@@ -57,7 +57,7 @@ export function customAlphabet (alphabet: string, size: number): () => string
|
|
57
57
|
* @param random A random bytes generator.
|
58
58
|
* @returns A random string generator.
|
59
59
|
*/
|
60
|
-
export function customRandom
|
60
|
+
export function customRandom(
|
61
61
|
alphabet: string,
|
62
62
|
size: number,
|
63
63
|
random: (bytes: number) => Uint8Array
|
@@ -68,7 +68,7 @@ export function customRandom (
|
|
68
68
|
*
|
69
69
|
* ```js
|
70
70
|
* import { urlAlphabet } from 'nanoid'
|
71
|
-
* const nanoid =
|
71
|
+
* const nanoid = customAlphabet(urlAlphabet, 10)
|
72
72
|
* nanoid() //=> "Uakgb_J5m9"
|
73
73
|
* ```
|
74
74
|
*/
|
@@ -85,4 +85,4 @@ export const urlAlphabet: string
|
|
85
85
|
* @param bytes Size of the array.
|
86
86
|
* @returns An array of random bytes.
|
87
87
|
*/
|
88
|
-
export function random
|
88
|
+
export function random(bytes: number): Uint8Array
|
package/index.dev.js
CHANGED
@@ -14,8 +14,7 @@ if (true) {
|
|
14
14
|
'React Native does not have a built-in secure random generator. ' +
|
15
15
|
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
|
16
16
|
'For secure IDs, import `react-native-get-random-values` ' +
|
17
|
-
'before Nano ID.
|
18
|
-
'and use `nanoid/async`.'
|
17
|
+
'before Nano ID.'
|
19
18
|
)
|
20
19
|
}
|
21
20
|
if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
|
@@ -67,8 +66,7 @@ let customRandom = (alphabet, size, getRandom) => {
|
|
67
66
|
while (j--) {
|
68
67
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
69
68
|
id += alphabet[bytes[j] & mask] || ''
|
70
|
-
|
71
|
-
if (id.length === +size) return id
|
69
|
+
if (id.length === size) return id
|
72
70
|
}
|
73
71
|
}
|
74
72
|
}
|
package/index.js
CHANGED
@@ -49,13 +49,12 @@ let customRandom = (alphabet, size, getRandom) => {
|
|
49
49
|
let id = ''
|
50
50
|
while (true) {
|
51
51
|
let bytes = getRandom(step)
|
52
|
-
// A compact alternative for `for (
|
52
|
+
// A compact alternative for `for (let i = 0; i < step; i++)`.
|
53
53
|
let i = step
|
54
54
|
while (i--) {
|
55
55
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
56
56
|
id += alphabet[bytes[i] & mask] || ''
|
57
|
-
|
58
|
-
if (id.length === +size) return id
|
57
|
+
if (id.length === size) return id
|
59
58
|
}
|
60
59
|
}
|
61
60
|
}
|
@@ -66,7 +65,7 @@ let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)
|
|
66
65
|
let nanoid = (size = 21) => {
|
67
66
|
let bytes = random(size)
|
68
67
|
let id = ''
|
69
|
-
// A compact alternative for `for (
|
68
|
+
// A compact alternative for `for (let i = 0; i < size; i++)`.
|
70
69
|
while (size--) {
|
71
70
|
// It is incorrect to use bytes exceeding the alphabet size.
|
72
71
|
// The following mask reduces the random byte in the 0-255 value
|
package/index.prod.js
CHANGED
@@ -14,8 +14,7 @@ if (false) {
|
|
14
14
|
'React Native does not have a built-in secure random generator. ' +
|
15
15
|
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
|
16
16
|
'For secure IDs, import `react-native-get-random-values` ' +
|
17
|
-
'before Nano ID.
|
18
|
-
'and use `nanoid/async`.'
|
17
|
+
'before Nano ID.'
|
19
18
|
)
|
20
19
|
}
|
21
20
|
if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
|
@@ -67,8 +66,7 @@ let customRandom = (alphabet, size, getRandom) => {
|
|
67
66
|
while (j--) {
|
68
67
|
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
69
68
|
id += alphabet[bytes[j] & mask] || ''
|
70
|
-
|
71
|
-
if (id.length === +size) return id
|
69
|
+
if (id.length === size) return id
|
72
70
|
}
|
73
71
|
}
|
74
72
|
}
|
package/non-secure/index.d.ts
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
* @param size Size of the ID. The default size is 21.
|
11
11
|
* @returns A random string.
|
12
12
|
*/
|
13
|
-
export function nanoid
|
13
|
+
export function nanoid(size?: number): string
|
14
14
|
|
15
15
|
/**
|
16
16
|
* Generate URL-friendly unique ID based on the custom alphabet.
|
@@ -27,4 +27,4 @@ export function nanoid (size?: number): string
|
|
27
27
|
* model.id = //=> "8ё56а"
|
28
28
|
* ```
|
29
29
|
*/
|
30
|
-
export function customAlphabet
|
30
|
+
export function customAlphabet(alphabet: string, size: number): () => string
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nanoid",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.22",
|
4
4
|
"description": "A tiny (108 bytes), secure URL-friendly unique string ID generator",
|
5
5
|
"keywords": [
|
6
6
|
"uuid",
|
@@ -28,10 +28,12 @@
|
|
28
28
|
".": {
|
29
29
|
"browser": {
|
30
30
|
"development": "./index.dev.js",
|
31
|
-
"production": "./index.prod.js"
|
31
|
+
"production": "./index.prod.js",
|
32
|
+
"default": "./index.prod.js"
|
32
33
|
},
|
33
34
|
"require": "./index.cjs",
|
34
35
|
"import": "./index.js",
|
36
|
+
"default": "./index.js",
|
35
37
|
"types": "./index.d.ts"
|
36
38
|
},
|
37
39
|
"./package.json": "./package.json",
|
@@ -39,17 +41,20 @@
|
|
39
41
|
"./async": {
|
40
42
|
"browser": "./async/index.browser.js",
|
41
43
|
"require": "./async/index.cjs",
|
42
|
-
"import": "./async/index.js"
|
44
|
+
"import": "./async/index.js",
|
45
|
+
"default": "./async/index.js"
|
43
46
|
},
|
44
47
|
"./non-secure/package.json": "./non-secure/package.json",
|
45
48
|
"./non-secure": {
|
46
49
|
"require": "./non-secure/index.cjs",
|
47
|
-
"import": "./non-secure/index.js"
|
50
|
+
"import": "./non-secure/index.js",
|
51
|
+
"default": "./non-secure/index.js"
|
48
52
|
},
|
49
53
|
"./url-alphabet/package.json": "./url-alphabet/package.json",
|
50
54
|
"./url-alphabet": {
|
51
55
|
"require": "./url-alphabet/index.cjs",
|
52
|
-
"import": "./url-alphabet/index.js"
|
56
|
+
"import": "./url-alphabet/index.js",
|
57
|
+
"default": "./url-alphabet/index.js"
|
53
58
|
},
|
54
59
|
"./index.d.ts": "./index.d.ts"
|
55
60
|
}
|
package/CHANGELOG.md
DELETED
@@ -1,235 +0,0 @@
|
|
1
|
-
# Change Log
|
2
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
-
|
4
|
-
## 3.1.18
|
5
|
-
* Fixed `package.exports`.
|
6
|
-
|
7
|
-
## 3.1.17
|
8
|
-
* Added files without `process`.
|
9
|
-
|
10
|
-
## 3.1.16
|
11
|
-
* Speeded up Nano ID 4 times (by Peter Boyer).
|
12
|
-
|
13
|
-
## 3.1.15
|
14
|
-
* Fixed `package.types` path.
|
15
|
-
|
16
|
-
## 3.1.14
|
17
|
-
* Added `package.types`.
|
18
|
-
|
19
|
-
## 3.1.13
|
20
|
-
* Removed Node.js 15.0.0 with `randomFillSync` regression from `engines.node`.
|
21
|
-
|
22
|
-
## 3.1.12
|
23
|
-
* Improved IE 11 docs.
|
24
|
-
|
25
|
-
## 3.1.11
|
26
|
-
* Fixed asynchronous `customAlphabet` in browser (by @LoneRifle).
|
27
|
-
|
28
|
-
## 3.1.10
|
29
|
-
* Fix ES modules support.
|
30
|
-
|
31
|
-
## 3.1.9
|
32
|
-
* Try to fix React Native Expo support.
|
33
|
-
|
34
|
-
## 3.1.8
|
35
|
-
* Add React Native Expo support.
|
36
|
-
|
37
|
-
## 3.1.7
|
38
|
-
* Clean up code.
|
39
|
-
|
40
|
-
## 3.1.6
|
41
|
-
* Avoid `self` using.
|
42
|
-
|
43
|
-
## 3.1.5
|
44
|
-
* Improve IE docs and warning.
|
45
|
-
|
46
|
-
## 3.1.4
|
47
|
-
* Restrict old Node.js 13 by `engines.node` (by Cansin Yildiz).
|
48
|
-
|
49
|
-
## 3.1.3
|
50
|
-
* Fix ES modules issue with CLI.
|
51
|
-
|
52
|
-
## 3.1.2
|
53
|
-
* Add shebang to CLI.
|
54
|
-
|
55
|
-
## 3.1.1
|
56
|
-
* Fix CLI.
|
57
|
-
|
58
|
-
## 3.1
|
59
|
-
* Add `npx nanoid` CLI.
|
60
|
-
|
61
|
-
## 3.0.2
|
62
|
-
* Fix docs (by Dylan Irlbeck ).
|
63
|
-
|
64
|
-
## 3.0.1
|
65
|
-
* Fix React Native warning on `non-secure` import (by Jia Huang).
|
66
|
-
|
67
|
-
## 3.0
|
68
|
-
**Migration guide:** <https://github.com/ai/nanoid/releases/tag/3.0.0>
|
69
|
-
* Move to ES2016 syntax. You need to use Babel for IE 11.
|
70
|
-
* Move to named exports `import { nanoid } from 'nanoid'`.
|
71
|
-
* Move `import url from 'nanoid/url'` to `import { urlAlphabet } from 'nanoid'`.
|
72
|
-
* Replace `format()` to `customRandom()`.
|
73
|
-
* Replace `generate()` to `customAlphabet()`.
|
74
|
-
* Remove `async/format`.
|
75
|
-
* Remove React Native support for `nanoid/async`.
|
76
|
-
* Add `nanoid.js` to use directly in browser from CDN.
|
77
|
-
* Add TypeScript type definitions.
|
78
|
-
* Add ES modules support for bundlers, Node.js, and React Native.
|
79
|
-
* Fix React Native support.
|
80
|
-
* Reduce size.
|
81
|
-
* Improve docs (by Dair Aidarkhanov).
|
82
|
-
|
83
|
-
## 2.1.11
|
84
|
-
* Reduce size (by Anton Evzhakov).
|
85
|
-
|
86
|
-
## 2.1.10
|
87
|
-
* Reduce size by 10% (by Anton Khlynovskiy).
|
88
|
-
|
89
|
-
## 2.1.9
|
90
|
-
* Reduce `format` and `async/format` size (by Dair Aidarkhanov).
|
91
|
-
|
92
|
-
## 2.1.8
|
93
|
-
* Improve React docs (by Nahum Zsilva).
|
94
|
-
|
95
|
-
## 2.1.7
|
96
|
-
* Reduce `index`, `async` and `non-secure` size (by @polemius).
|
97
|
-
|
98
|
-
## 2.1.6
|
99
|
-
* Reduce size (by Stas Lashmanov).
|
100
|
-
* Return fast mask for Node.js.
|
101
|
-
|
102
|
-
## 2.1.5
|
103
|
-
* Reduce size (by Max Graey).
|
104
|
-
* Fix IE support.
|
105
|
-
|
106
|
-
## 2.1.4
|
107
|
-
* Reduce `generate` size (by Vsevolod Rodionov).
|
108
|
-
* Reduce `format` and `format` size (by Victor).
|
109
|
-
* Reduce `async`, `non-secure` and `non-secure/generate` size.
|
110
|
-
* Speed up `format` and `async/format` (by Max Graey).
|
111
|
-
* Improve development process on Windows (by Stanislav Lashmanov).
|
112
|
-
|
113
|
-
## 2.1.3
|
114
|
-
* Improve performance (by Stephen Richardson).
|
115
|
-
* Reduce size (by Stephen Richardson).
|
116
|
-
|
117
|
-
## 2.1.2
|
118
|
-
* Improve docs.
|
119
|
-
|
120
|
-
## 2.1.1
|
121
|
-
* Fix React Native support (by Shawn Hwei).
|
122
|
-
|
123
|
-
## 2.1
|
124
|
-
* Improve React Native support (by Sebastian Werner).
|
125
|
-
|
126
|
-
## 2.0.4
|
127
|
-
* Improve error text for React Native (by Sebastian Werner).
|
128
|
-
|
129
|
-
## 2.0.3
|
130
|
-
* Fix freeze on string in ID length.
|
131
|
-
|
132
|
-
## 2.0.2
|
133
|
-
* Improve docs (by Sylvanus Kateile and Mark Stosberg).
|
134
|
-
|
135
|
-
## 2.0.1
|
136
|
-
* Reduce npm package size.
|
137
|
-
* Mark package as not having side effects (by @xiaody).
|
138
|
-
|
139
|
-
## 2.0
|
140
|
-
* Use `-` instead of `~` in default alphabet to by file name safe.
|
141
|
-
* Add `nanoid/non-secure/generate`.
|
142
|
-
|
143
|
-
## 1.3.4
|
144
|
-
* Reduce `non-secure` size.
|
145
|
-
* Add `async` callback type check.
|
146
|
-
|
147
|
-
## 1.3.3
|
148
|
-
* Fix `nanoid/async` performance regression.
|
149
|
-
* Fix old Node.js `not seeded` issue in synchronous version too.
|
150
|
-
|
151
|
-
## 1.3.2
|
152
|
-
* Fix random generator `not seeded` issue of old Node.js.
|
153
|
-
|
154
|
-
## 1.3.1
|
155
|
-
* Reduce library size.
|
156
|
-
|
157
|
-
## 1.3
|
158
|
-
* Add `nanoid/async/format` and `nanoid/async/generate`.
|
159
|
-
* Improve synchronous API performance.
|
160
|
-
* Reduce `url` size (by Daniil Poroshin).
|
161
|
-
* Improve React Native docs (by joelgetaction).
|
162
|
-
|
163
|
-
## 1.2.6
|
164
|
-
* Reduce library size (by rqrqrqrq).
|
165
|
-
|
166
|
-
## 1.2.5
|
167
|
-
* Fix Node.js 6.11.1 support (by Andrey Belym).
|
168
|
-
|
169
|
-
## 1.2.4
|
170
|
-
* Speed up Node.js secure generators (by Dmitriy Tsvettsikh).
|
171
|
-
|
172
|
-
## 1.2.3
|
173
|
-
* Fix JSDoc (by Hendry Sadrak).
|
174
|
-
|
175
|
-
## 1.2.2
|
176
|
-
* Fix distribution in `nanoid/non-secure` (by Eatall).
|
177
|
-
|
178
|
-
## 1.2.1
|
179
|
-
* Fix old Node.js support.
|
180
|
-
|
181
|
-
## 1.2
|
182
|
-
* Add `nanoid/async`.
|
183
|
-
* Fix `nanoid/non-secure` JSDoc.
|
184
|
-
* Add Chinese documentation (by Wenliang Dai).
|
185
|
-
* Speed up and reduce size of `nanoid/non-secure` (by Ori Livni).
|
186
|
-
|
187
|
-
## 1.1.1
|
188
|
-
* Improve performance and reduce size of non-secure ID generator.
|
189
|
-
|
190
|
-
## 1.1
|
191
|
-
* Add non-secure ID generator.
|
192
|
-
* Suggest to use non-secure ID generator for React Native developers.
|
193
|
-
* Reduce size.
|
194
|
-
|
195
|
-
## 1.0.7
|
196
|
-
* Fix documentation.
|
197
|
-
|
198
|
-
## 1.0.6
|
199
|
-
* Fix documentation.
|
200
|
-
|
201
|
-
## 1.0.5
|
202
|
-
* Reduce `nanoid/index` size (by Anton Khlynovskiy).
|
203
|
-
|
204
|
-
## 1.0.4
|
205
|
-
* Reduce npm package size.
|
206
|
-
|
207
|
-
## 1.0.3
|
208
|
-
* Reduce npm package size.
|
209
|
-
|
210
|
-
## 1.0.2
|
211
|
-
* Fix Web Workers support (by Zachary Golba).
|
212
|
-
|
213
|
-
## 1.0.1
|
214
|
-
* Reduce `nanoid/index` size (by Anton Khlynovskiy).
|
215
|
-
|
216
|
-
## 1.0
|
217
|
-
* Use 21 symbols by default (by David Klebanoff).
|
218
|
-
|
219
|
-
## 0.2.2
|
220
|
-
* Reduce `nanoid/generate` size (by Anton Khlynovskiy).
|
221
|
-
* Speed up Node.js random generator.
|
222
|
-
|
223
|
-
## 0.2.1
|
224
|
-
* Fix documentation (by Piper Chester).
|
225
|
-
|
226
|
-
## 0.2
|
227
|
-
* Add `size` argument to `nanoid()`.
|
228
|
-
* Improve performance by 50%.
|
229
|
-
* Reduce library size by 26% (by Vsevolod Rodionov and Oleg Mokhov).
|
230
|
-
|
231
|
-
## 0.1.1
|
232
|
-
* Reduce library size by 5%.
|
233
|
-
|
234
|
-
## 0.1
|
235
|
-
* Initial release.
|