nanoid 5.0.5 → 5.0.7
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/bin/nanoid.js +1 -1
- package/index.browser.js +2 -2
- package/index.js +3 -3
- package/package.json +4 -1
package/bin/nanoid.js
CHANGED
package/index.browser.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { urlAlphabet } from './url-alphabet/index.js'
|
1
|
+
import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'
|
2
2
|
export { urlAlphabet } from './url-alphabet/index.js'
|
3
3
|
export let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
4
4
|
export let customRandom = (alphabet, defaultSize, getRandom) => {
|
@@ -22,7 +22,7 @@ export let nanoid = (size = 21) => {
|
|
22
22
|
let id = ''
|
23
23
|
let bytes = crypto.getRandomValues(new Uint8Array(size))
|
24
24
|
while (size--) {
|
25
|
-
id +=
|
25
|
+
id += scopedUrlAlphabet[bytes[size] & 63]
|
26
26
|
}
|
27
27
|
return id
|
28
28
|
}
|
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { webcrypto as crypto } from 'node:crypto'
|
2
|
-
import { urlAlphabet } from './url-alphabet/index.js'
|
3
|
-
export { urlAlphabet }
|
2
|
+
import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'
|
3
|
+
export { urlAlphabet } from './url-alphabet/index.js'
|
4
4
|
const POOL_SIZE_MULTIPLIER = 128
|
5
5
|
let pool, poolOffset
|
6
6
|
function fillPool(bytes) {
|
@@ -40,7 +40,7 @@ export function nanoid(size = 21) {
|
|
40
40
|
fillPool((size -= 0))
|
41
41
|
let id = ''
|
42
42
|
for (let i = poolOffset - size; i < poolOffset; i++) {
|
43
|
-
id +=
|
43
|
+
id += scopedUrlAlphabet[pool[i] & 63]
|
44
44
|
}
|
45
45
|
return id
|
46
46
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nanoid",
|
3
|
-
"version": "5.0.
|
3
|
+
"version": "5.0.7",
|
4
4
|
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
|
5
5
|
"keywords": [
|
6
6
|
"uuid",
|
@@ -32,6 +32,9 @@
|
|
32
32
|
"browser": {
|
33
33
|
"./index.js": "./index.browser.js"
|
34
34
|
},
|
35
|
+
"react-native": {
|
36
|
+
"./index.js": "./index.browser.js"
|
37
|
+
},
|
35
38
|
"bin": "./bin/nanoid.js",
|
36
39
|
"sideEffects": false,
|
37
40
|
"types": "./index.d.ts"
|