nanoid 5.0.8 → 5.0.9

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.
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.** 116 bytes (minified and brotlied). No dependencies.
13
+ * **Small.** 118 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/index.browser.js CHANGED
@@ -8,19 +8,19 @@ export let customRandom = (alphabet, defaultSize, getRandom) => {
8
8
  let id = ''
9
9
  while (true) {
10
10
  let bytes = getRandom(step)
11
- let j = step
11
+ let j = step | 0
12
12
  while (j--) {
13
13
  id += alphabet[bytes[j] & mask] || ''
14
- if (id.length === size) return id
14
+ if (id.length >= size) return id
15
15
  }
16
16
  }
17
17
  }
18
18
  }
19
19
  export let customAlphabet = (alphabet, size = 21) =>
20
- customRandom(alphabet, size, random)
20
+ customRandom(alphabet, size | 0, random)
21
21
  export let nanoid = (size = 21) => {
22
22
  let id = ''
23
- let bytes = crypto.getRandomValues(new Uint8Array(size))
23
+ let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
24
24
  while (size--) {
25
25
  id += scopedUrlAlphabet[bytes[size] & 63]
26
26
  }
package/index.js CHANGED
@@ -15,7 +15,7 @@ function fillPool(bytes) {
15
15
  poolOffset += bytes
16
16
  }
17
17
  export function random(bytes) {
18
- fillPool((bytes -= 0))
18
+ fillPool((bytes |= 0))
19
19
  return pool.subarray(poolOffset - bytes, poolOffset)
20
20
  }
21
21
  export function customRandom(alphabet, defaultSize, getRandom) {
@@ -28,7 +28,7 @@ export function customRandom(alphabet, defaultSize, getRandom) {
28
28
  let i = step
29
29
  while (i--) {
30
30
  id += alphabet[bytes[i] & mask] || ''
31
- if (id.length === size) return id
31
+ if (id.length >= size) return id
32
32
  }
33
33
  }
34
34
  }
@@ -37,7 +37,7 @@ export function customAlphabet(alphabet, size = 21) {
37
37
  return customRandom(alphabet, size, random)
38
38
  }
39
39
  export function nanoid(size = 21) {
40
- fillPool((size -= 0))
40
+ fillPool((size |= 0))
41
41
  let id = ''
42
42
  for (let i = poolOffset - size; i < poolOffset; i++) {
43
43
  id += scopedUrlAlphabet[pool[i] & 63]
@@ -3,7 +3,7 @@ let urlAlphabet =
3
3
  export let customAlphabet = (alphabet, defaultSize = 21) => {
4
4
  return (size = defaultSize) => {
5
5
  let id = ''
6
- let i = size
6
+ let i = size | 0
7
7
  while (i--) {
8
8
  id += alphabet[(Math.random() * alphabet.length) | 0]
9
9
  }
@@ -12,7 +12,7 @@ export let customAlphabet = (alphabet, defaultSize = 21) => {
12
12
  }
13
13
  export let nanoid = (size = 21) => {
14
14
  let id = ''
15
- let i = size
15
+ let i = size | 0
16
16
  while (i--) {
17
17
  id += urlAlphabet[(Math.random() * 64) | 0]
18
18
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nanoid",
3
- "version": "5.0.8",
4
- "description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
3
+ "version": "5.0.9",
4
+ "description": "A tiny (118 bytes), secure URL-friendly unique string ID generator",
5
5
  "keywords": [
6
6
  "uuid",
7
7
  "random",