nanoid 5.0.3 → 5.0.5

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 CHANGED
@@ -10,7 +10,7 @@ A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
10
10
  > “An amazing level of senseless perfectionism,
11
11
  > which is simply impossible not to respect.”
12
12
 
13
- * **Small.** 130 bytes (minified and gzipped). No dependencies.
13
+ * **Small.** 116 bytes (minified and brotlied). No dependencies.
14
14
  [Size Limit] controls the size.
15
15
  * **Safe.** It uses hardware random generator. Can be used in clusters.
16
16
  * **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
package/bin/nanoid.js CHANGED
@@ -8,18 +8,17 @@ function error(msg) {
8
8
  process.exit(1)
9
9
  }
10
10
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
11
- print(`
12
- Usage
13
- $ nanoid [options]
14
- Options
15
- -s, --size Generated ID size
16
- -a, --alphabet Alphabet to use
17
- -h, --help Show this help
18
- Examples
19
- $ nanoid -s 15
20
- S9sBF77U6sDB8Yg
21
- $ nanoid --size 10 --alphabet abc
22
- bcabababca`)
11
+ print(`Usage
12
+ $ nanoid [options]
13
+ Options
14
+ -s, --size Generated ID size
15
+ -a, --alphabet Alphabet to use
16
+ -h, --help Show this help
17
+ Examples
18
+ $ nanoid -s 15
19
+ S9sBF77U6sDB8Yg
20
+ $ nanoid --size 10 --alphabet abc
21
+ bcabababca`)
23
22
  process.exit()
24
23
  }
25
24
  let alphabet, size
package/index.browser.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { urlAlphabet } from './url-alphabet/index.js'
1
2
  export { urlAlphabet } from './url-alphabet/index.js'
2
3
  export let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
3
4
  export let customRandom = (alphabet, defaultSize, getRandom) => {
@@ -17,17 +18,11 @@ export let customRandom = (alphabet, defaultSize, getRandom) => {
17
18
  }
18
19
  export let customAlphabet = (alphabet, size = 21) =>
19
20
  customRandom(alphabet, size, random)
20
- export let nanoid = (size = 21) =>
21
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
22
- byte &= 63
23
- if (byte < 36) {
24
- id += byte.toString(36)
25
- } else if (byte < 62) {
26
- id += (byte - 26).toString(36).toUpperCase()
27
- } else if (byte > 62) {
28
- id += '-'
29
- } else {
30
- id += '_'
31
- }
32
- return id
33
- }, '')
21
+ export let nanoid = (size = 21) => {
22
+ let id = ''
23
+ let bytes = crypto.getRandomValues(new Uint8Array(size))
24
+ while (size--) {
25
+ id += urlAlphabet[bytes[size] & 63]
26
+ }
27
+ return id
28
+ }
package/nanoid.js CHANGED
@@ -1 +1 @@
1
- export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),"");
1
+ let a="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";export let nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(let n=0;n<e;n++)t+=a[63&r[n]];return t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoid",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
5
5
  "keywords": [
6
6
  "uuid",