nanoid 3.3.6 → 3.3.8

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.
@@ -1,21 +1,34 @@
1
+ // This alphabet uses `A-Za-z0-9_-` symbols.
2
+ // The order of characters is optimized for better gzip and brotli compression.
3
+ // References to the same file (works both for gzip and brotli):
4
+ // `'use`, `andom`, and `rict'`
5
+ // References to the brotli default dictionary:
6
+ // `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
1
7
  let urlAlphabet =
2
8
  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
9
+
3
10
  let customAlphabet = (alphabet, defaultSize = 21) => {
4
11
  return (size = defaultSize) => {
5
12
  let id = ''
6
- let i = size
13
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
14
+ let i = size | 0
7
15
  while (i--) {
16
+ // `| 0` is more compact and faster than `Math.floor()`.
8
17
  id += alphabet[(Math.random() * alphabet.length) | 0]
9
18
  }
10
19
  return id
11
20
  }
12
21
  }
22
+
13
23
  let nanoid = (size = 21) => {
14
24
  let id = ''
15
- let i = size
25
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
26
+ let i = size | 0
16
27
  while (i--) {
28
+ // `| 0` is more compact and faster than `Math.floor()`.
17
29
  id += urlAlphabet[(Math.random() * 64) | 0]
18
30
  }
19
31
  return id
20
32
  }
33
+
21
34
  export { nanoid, customAlphabet }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoid",
3
- "version": "3.3.6",
3
+ "version": "3.3.8",
4
4
  "description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
5
5
  "keywords": [
6
6
  "uuid",
@@ -35,31 +35,53 @@
35
35
  "module": "index.js",
36
36
  "exports": {
37
37
  ".": {
38
- "types": "./index.d.ts",
39
38
  "browser": "./index.browser.js",
40
- "require": "./index.cjs",
41
- "import": "./index.js",
39
+ "require": {
40
+ "types": "./index.d.cts",
41
+ "default": "./index.cjs"
42
+ },
43
+ "import": {
44
+ "types": "./index.d.ts",
45
+ "default": "./index.js"
46
+ },
42
47
  "default": "./index.js"
43
48
  },
44
- "./index.d.ts": "./index.d.ts",
45
49
  "./package.json": "./package.json",
46
50
  "./async/package.json": "./async/package.json",
47
51
  "./async": {
48
52
  "browser": "./async/index.browser.js",
49
- "require": "./async/index.cjs",
50
- "import": "./async/index.js",
53
+ "require": {
54
+ "types": "./index.d.cts",
55
+ "default": "./async/index.cjs"
56
+ },
57
+ "import": {
58
+ "types": "./index.d.ts",
59
+ "default": "./async/index.js"
60
+ },
51
61
  "default": "./async/index.js"
52
62
  },
53
63
  "./non-secure/package.json": "./non-secure/package.json",
54
64
  "./non-secure": {
55
- "require": "./non-secure/index.cjs",
56
- "import": "./non-secure/index.js",
65
+ "require": {
66
+ "types": "./index.d.cts",
67
+ "default": "./non-secure/index.cjs"
68
+ },
69
+ "import": {
70
+ "types": "./index.d.ts",
71
+ "default": "./non-secure/index.js"
72
+ },
57
73
  "default": "./non-secure/index.js"
58
74
  },
59
75
  "./url-alphabet/package.json": "./url-alphabet/package.json",
60
76
  "./url-alphabet": {
61
- "require": "./url-alphabet/index.cjs",
62
- "import": "./url-alphabet/index.js",
77
+ "require": {
78
+ "types": "./index.d.cts",
79
+ "default": "./url-alphabet/index.cjs"
80
+ },
81
+ "import": {
82
+ "types": "./index.d.ts",
83
+ "default": "./url-alphabet/index.js"
84
+ },
63
85
  "default": "./url-alphabet/index.js"
64
86
  }
65
87
  }
@@ -1,3 +1,7 @@
1
+ // This alphabet uses `A-Za-z0-9_-` symbols.
2
+ // The order of characters is optimized for better gzip and brotli compression.
3
+ // Same as in non-secure/index.js
1
4
  let urlAlphabet =
2
5
  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
6
+
3
7
  module.exports = { urlAlphabet }
@@ -1,3 +1,7 @@
1
+ // This alphabet uses `A-Za-z0-9_-` symbols.
2
+ // The order of characters is optimized for better gzip and brotli compression.
3
+ // Same as in non-secure/index.js
1
4
  let urlAlphabet =
2
5
  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
6
+
3
7
  export { urlAlphabet }