@kikiutils/shared 12.0.0 → 13.0.1

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.
Files changed (211) hide show
  1. package/README.md +1 -1
  2. package/dist/buffer.d.ts +7 -3
  3. package/dist/buffer.d.ts.map +1 -1
  4. package/dist/buffer.js +42 -0
  5. package/dist/buffer.js.map +1 -0
  6. package/dist/clipboard.d.ts +8 -6
  7. package/dist/clipboard.d.ts.map +1 -1
  8. package/dist/clipboard.js +86 -0
  9. package/dist/clipboard.js.map +1 -0
  10. package/dist/consola.d.ts +8 -2
  11. package/dist/consola.d.ts.map +1 -1
  12. package/dist/consola.js +32 -0
  13. package/dist/consola.js.map +1 -0
  14. package/dist/crypto-hash.d.ts +16 -26
  15. package/dist/crypto-hash.d.ts.map +1 -1
  16. package/dist/crypto-hash.js +37 -0
  17. package/dist/crypto-hash.js.map +1 -0
  18. package/dist/datetime.d.ts +13 -9
  19. package/dist/datetime.d.ts.map +1 -1
  20. package/dist/datetime.js +131 -0
  21. package/dist/datetime.js.map +1 -0
  22. package/dist/element-plus.d.ts +8 -4
  23. package/dist/element-plus.d.ts.map +1 -1
  24. package/dist/element-plus.js +37 -0
  25. package/dist/element-plus.js.map +1 -0
  26. package/dist/enum.d.ts +6 -3
  27. package/dist/enum.d.ts.map +1 -1
  28. package/dist/enum.js +108 -0
  29. package/dist/enum.js.map +1 -0
  30. package/dist/env.d.ts +12 -9
  31. package/dist/env.d.ts.map +1 -1
  32. package/dist/env.js +51 -0
  33. package/dist/env.js.map +1 -0
  34. package/dist/general.d.ts +5 -2
  35. package/dist/general.d.ts.map +1 -1
  36. package/dist/general.js +8 -0
  37. package/dist/general.js.map +1 -0
  38. package/dist/hash.d.ts +7 -4
  39. package/dist/hash.d.ts.map +1 -1
  40. package/dist/hash.js +20 -0
  41. package/dist/hash.js.map +1 -0
  42. package/dist/math.d.ts +20 -17
  43. package/dist/math.d.ts.map +1 -1
  44. package/dist/math.js +36 -0
  45. package/dist/math.js.map +1 -0
  46. package/dist/number.d.ts +7 -2
  47. package/dist/number.d.ts.map +1 -1
  48. package/dist/number.js +32 -0
  49. package/dist/number.js.map +1 -0
  50. package/dist/object.d.ts +4 -1
  51. package/dist/object.d.ts.map +1 -1
  52. package/dist/object.js +42 -0
  53. package/dist/object.js.map +1 -0
  54. package/dist/pino.d.ts +8 -2
  55. package/dist/pino.d.ts.map +1 -1
  56. package/dist/pino.js +40 -0
  57. package/dist/pino.js.map +1 -0
  58. package/dist/random.d.ts +4 -1
  59. package/dist/random.d.ts.map +1 -1
  60. package/dist/random.js +31 -0
  61. package/dist/random.js.map +1 -0
  62. package/dist/storage/enhanced/local/core.d.ts +45 -42
  63. package/dist/storage/enhanced/local/core.d.ts.map +1 -1
  64. package/dist/storage/enhanced/local/core.js +63 -0
  65. package/dist/storage/enhanced/local/core.js.map +1 -0
  66. package/dist/storage/enhanced/local/index.d.ts +3 -3
  67. package/dist/storage/enhanced/local/index.js +4 -0
  68. package/dist/storage/enhanced/local/keyed-store.d.ts +14 -11
  69. package/dist/storage/enhanced/local/keyed-store.d.ts.map +1 -1
  70. package/dist/storage/enhanced/local/keyed-store.js +36 -0
  71. package/dist/storage/enhanced/local/keyed-store.js.map +1 -0
  72. package/dist/storage/enhanced/redis/core.d.ts +64 -59
  73. package/dist/storage/enhanced/redis/core.d.ts.map +1 -1
  74. package/dist/storage/enhanced/redis/core.js +85 -0
  75. package/dist/storage/enhanced/redis/core.js.map +1 -0
  76. package/dist/storage/enhanced/redis/index.d.ts +3 -3
  77. package/dist/storage/enhanced/redis/index.js +4 -0
  78. package/dist/storage/enhanced/redis/keyed-store.d.ts +19 -14
  79. package/dist/storage/enhanced/redis/keyed-store.d.ts.map +1 -1
  80. package/dist/storage/enhanced/redis/keyed-store.js +41 -0
  81. package/dist/storage/enhanced/redis/keyed-store.js.map +1 -0
  82. package/dist/storage/lru/keyed-store.d.ts +21 -16
  83. package/dist/storage/lru/keyed-store.d.ts.map +1 -1
  84. package/dist/storage/lru/keyed-store.js +40 -0
  85. package/dist/storage/lru/keyed-store.js.map +1 -0
  86. package/dist/string.d.ts +5 -2
  87. package/dist/string.d.ts.map +1 -1
  88. package/dist/string.js +42 -0
  89. package/dist/string.js.map +1 -0
  90. package/dist/url.d.ts +4 -1
  91. package/dist/url.d.ts.map +1 -1
  92. package/dist/url.js +21 -0
  93. package/dist/url.js.map +1 -0
  94. package/dist/vue.d.ts +10 -5
  95. package/dist/vue.d.ts.map +1 -1
  96. package/dist/vue.js +58 -0
  97. package/dist/vue.js.map +1 -0
  98. package/dist/web.d.ts +5 -2
  99. package/dist/web.d.ts.map +1 -1
  100. package/dist/web.js +32 -0
  101. package/dist/web.js.map +1 -0
  102. package/package.json +43 -27
  103. package/src/env.ts +1 -1
  104. package/src/vue.ts +1 -1
  105. package/src/web.ts +1 -1
  106. package/dist/buffer.cjs +0 -43
  107. package/dist/buffer.cjs.map +0 -1
  108. package/dist/buffer.mjs +0 -41
  109. package/dist/buffer.mjs.map +0 -1
  110. package/dist/clipboard.cjs +0 -91
  111. package/dist/clipboard.cjs.map +0 -1
  112. package/dist/clipboard.mjs +0 -88
  113. package/dist/clipboard.mjs.map +0 -1
  114. package/dist/consola.cjs +0 -35
  115. package/dist/consola.cjs.map +0 -1
  116. package/dist/consola.mjs +0 -32
  117. package/dist/consola.mjs.map +0 -1
  118. package/dist/crypto-hash.cjs +0 -61
  119. package/dist/crypto-hash.cjs.map +0 -1
  120. package/dist/crypto-hash.mjs +0 -50
  121. package/dist/crypto-hash.mjs.map +0 -1
  122. package/dist/datetime.cjs +0 -134
  123. package/dist/datetime.cjs.map +0 -1
  124. package/dist/datetime.mjs +0 -130
  125. package/dist/datetime.mjs.map +0 -1
  126. package/dist/element-plus.cjs +0 -37
  127. package/dist/element-plus.cjs.map +0 -1
  128. package/dist/element-plus.mjs +0 -35
  129. package/dist/element-plus.mjs.map +0 -1
  130. package/dist/enum.cjs +0 -112
  131. package/dist/enum.cjs.map +0 -1
  132. package/dist/enum.mjs +0 -108
  133. package/dist/enum.mjs.map +0 -1
  134. package/dist/env.cjs +0 -53
  135. package/dist/env.cjs.map +0 -1
  136. package/dist/env.mjs +0 -50
  137. package/dist/env.mjs.map +0 -1
  138. package/dist/general.cjs +0 -10
  139. package/dist/general.cjs.map +0 -1
  140. package/dist/general.mjs +0 -8
  141. package/dist/general.mjs.map +0 -1
  142. package/dist/hash.cjs +0 -36
  143. package/dist/hash.cjs.map +0 -1
  144. package/dist/hash.mjs +0 -31
  145. package/dist/hash.mjs.map +0 -1
  146. package/dist/math.cjs +0 -38
  147. package/dist/math.cjs.map +0 -1
  148. package/dist/math.mjs +0 -36
  149. package/dist/math.mjs.map +0 -1
  150. package/dist/number.cjs +0 -32
  151. package/dist/number.cjs.map +0 -1
  152. package/dist/number.mjs +0 -30
  153. package/dist/number.mjs.map +0 -1
  154. package/dist/object.cjs +0 -55
  155. package/dist/object.cjs.map +0 -1
  156. package/dist/object.mjs +0 -53
  157. package/dist/object.mjs.map +0 -1
  158. package/dist/pino.cjs +0 -42
  159. package/dist/pino.cjs.map +0 -1
  160. package/dist/pino.mjs +0 -39
  161. package/dist/pino.mjs.map +0 -1
  162. package/dist/random.cjs +0 -31
  163. package/dist/random.cjs.map +0 -1
  164. package/dist/random.mjs +0 -29
  165. package/dist/random.mjs.map +0 -1
  166. package/dist/storage/enhanced/local/core.cjs +0 -105
  167. package/dist/storage/enhanced/local/core.cjs.map +0 -1
  168. package/dist/storage/enhanced/local/core.mjs +0 -103
  169. package/dist/storage/enhanced/local/core.mjs.map +0 -1
  170. package/dist/storage/enhanced/local/index.cjs +0 -10
  171. package/dist/storage/enhanced/local/index.cjs.map +0 -1
  172. package/dist/storage/enhanced/local/index.d.ts.map +0 -1
  173. package/dist/storage/enhanced/local/index.mjs +0 -3
  174. package/dist/storage/enhanced/local/index.mjs.map +0 -1
  175. package/dist/storage/enhanced/local/keyed-store.cjs +0 -41
  176. package/dist/storage/enhanced/local/keyed-store.cjs.map +0 -1
  177. package/dist/storage/enhanced/local/keyed-store.mjs +0 -39
  178. package/dist/storage/enhanced/local/keyed-store.mjs.map +0 -1
  179. package/dist/storage/enhanced/redis/core.cjs +0 -144
  180. package/dist/storage/enhanced/redis/core.cjs.map +0 -1
  181. package/dist/storage/enhanced/redis/core.mjs +0 -142
  182. package/dist/storage/enhanced/redis/core.mjs.map +0 -1
  183. package/dist/storage/enhanced/redis/index.cjs +0 -10
  184. package/dist/storage/enhanced/redis/index.cjs.map +0 -1
  185. package/dist/storage/enhanced/redis/index.d.ts.map +0 -1
  186. package/dist/storage/enhanced/redis/index.mjs +0 -3
  187. package/dist/storage/enhanced/redis/index.mjs.map +0 -1
  188. package/dist/storage/enhanced/redis/keyed-store.cjs +0 -46
  189. package/dist/storage/enhanced/redis/keyed-store.cjs.map +0 -1
  190. package/dist/storage/enhanced/redis/keyed-store.mjs +0 -44
  191. package/dist/storage/enhanced/redis/keyed-store.mjs.map +0 -1
  192. package/dist/storage/lru/keyed-store.cjs +0 -49
  193. package/dist/storage/lru/keyed-store.cjs.map +0 -1
  194. package/dist/storage/lru/keyed-store.mjs +0 -47
  195. package/dist/storage/lru/keyed-store.mjs.map +0 -1
  196. package/dist/string.cjs +0 -45
  197. package/dist/string.cjs.map +0 -1
  198. package/dist/string.mjs +0 -43
  199. package/dist/string.mjs.map +0 -1
  200. package/dist/url.cjs +0 -21
  201. package/dist/url.cjs.map +0 -1
  202. package/dist/url.mjs +0 -19
  203. package/dist/url.mjs.map +0 -1
  204. package/dist/vue.cjs +0 -64
  205. package/dist/vue.cjs.map +0 -1
  206. package/dist/vue.mjs +0 -59
  207. package/dist/vue.mjs.map +0 -1
  208. package/dist/web.cjs +0 -35
  209. package/dist/web.cjs.map +0 -1
  210. package/dist/web.mjs +0 -32
  211. package/dist/web.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@kikiutils/shared",
3
- "version": "12.0.0",
3
+ "type": "module",
4
+ "version": "13.0.1",
4
5
  "description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
5
6
  "author": "kiki-kanri",
6
7
  "license": "MIT",
@@ -32,31 +33,43 @@
32
33
  ],
33
34
  "sideEffects": false,
34
35
  "exports": {
35
- "./*": {
36
- "types": "./dist/*.d.ts",
37
- "import": "./dist/*.mjs",
38
- "require": "./dist/*.cjs"
39
- },
40
- "./storage/enhanced/local": {
41
- "types": "./dist/storage/enhanced/local/index.d.ts",
42
- "import": "./dist/storage/enhanced/local/index.mjs",
43
- "require": "./dist/storage/enhanced/local/index.cjs"
44
- },
45
- "./storage/enhanced/redis": {
46
- "types": "./dist/storage/enhanced/redis/index.d.ts",
47
- "import": "./dist/storage/enhanced/redis/index.mjs",
48
- "require": "./dist/storage/enhanced/redis/index.cjs"
49
- }
36
+ "./buffer": "./dist/buffer.js",
37
+ "./clipboard": "./dist/clipboard.js",
38
+ "./consola": "./dist/consola.js",
39
+ "./crypto-hash": "./dist/crypto-hash.js",
40
+ "./datetime": "./dist/datetime.js",
41
+ "./element-plus": "./dist/element-plus.js",
42
+ "./enum": "./dist/enum.js",
43
+ "./env": "./dist/env.js",
44
+ "./general": "./dist/general.js",
45
+ "./hash": "./dist/hash.js",
46
+ "./math": "./dist/math.js",
47
+ "./number": "./dist/number.js",
48
+ "./object": "./dist/object.js",
49
+ "./pino": "./dist/pino.js",
50
+ "./random": "./dist/random.js",
51
+ "./storage/enhanced/local": "./dist/storage/enhanced/local/index.js",
52
+ "./storage/enhanced/local/core": "./dist/storage/enhanced/local/core.js",
53
+ "./storage/enhanced/local/keyed-store": "./dist/storage/enhanced/local/keyed-store.js",
54
+ "./storage/enhanced/redis": "./dist/storage/enhanced/redis/index.js",
55
+ "./storage/enhanced/redis/core": "./dist/storage/enhanced/redis/core.js",
56
+ "./storage/enhanced/redis/keyed-store": "./dist/storage/enhanced/redis/keyed-store.js",
57
+ "./storage/lru/keyed-store": "./dist/storage/lru/keyed-store.js",
58
+ "./string": "./dist/string.js",
59
+ "./url": "./dist/url.js",
60
+ "./vue": "./dist/vue.js",
61
+ "./web": "./dist/web.js",
62
+ "./package.json": "./package.json"
50
63
  },
51
64
  "files": [
52
65
  "./dist",
53
66
  "./src"
54
67
  ],
55
68
  "engines": {
56
- "node": ">=20.19.0"
69
+ "node": ">=22.0.0"
57
70
  },
58
71
  "scripts": {
59
- "build": "ts-project-builder './src/**/*.ts' --clean --preserve-modules --sourcemaps",
72
+ "build": "tsdown",
60
73
  "bumplog": "changelogen --bump --hideAuthorEmail",
61
74
  "depcheck": "depcheck",
62
75
  "lint": "eslint --max-warnings 0",
@@ -130,10 +143,10 @@
130
143
  },
131
144
  "devDependencies": {
132
145
  "@kikiutils/changelogen": "^0.9.0",
133
- "@kikiutils/eslint-config": "^2.1.0",
134
- "@kikiutils/tsconfigs": "^5.0.4",
146
+ "@kikiutils/eslint-config": "^3.0.1",
147
+ "@kikiutils/tsconfigs": "^5.0.5",
135
148
  "@noble/hashes": "^2.0.0",
136
- "@types/node": "^24.3.0",
149
+ "@types/node": "^24.3.3",
137
150
  "@vitest/coverage-v8": "^3.2.4",
138
151
  "async-validator": "^4.2.5",
139
152
  "consola": "^3.4.2",
@@ -141,19 +154,22 @@
141
154
  "date-fns": "^4.1.0",
142
155
  "decimal.js": "^10.6.0",
143
156
  "depcheck": "^1.4.7",
144
- "element-plus": "^2.11.1",
157
+ "element-plus": "^2.11.2",
145
158
  "ioredis": "^5.7.0",
146
- "jsdom": "^26.1.0",
147
- "lru-cache": "^11.1.0",
159
+ "jsdom": "^27.0.0",
160
+ "lru-cache": "^11.2.1",
148
161
  "millify": "^6.1.0",
149
- "pino": "^9.9.0",
162
+ "pino": "^9.9.5",
150
163
  "pino-pretty": "^13.1.1",
164
+ "publint": "^0.3.12",
151
165
  "superjson": "^2.2.2",
152
- "ts-project-builder": "^5.0.2",
153
166
  "ts-unused-exports": "^11.0.1",
167
+ "tsconfck": "^3.1.6",
168
+ "tsdown": "^0.15.1",
154
169
  "typescript": "^5.9.2",
170
+ "unplugin-unused": "^0.5.3",
155
171
  "vitest": "^3.2.4",
156
- "vue": "^3.5.20",
172
+ "vue": "^3.5.21",
157
173
  "vue-router": "^4.5.1"
158
174
  },
159
175
  "pnpm": {
package/src/env.ts CHANGED
@@ -42,7 +42,7 @@ export class EnvironmentNotFoundError extends Error {
42
42
  * checkAndGetEnvValue('API_KEY'); // ❌ Throws EnvironmentNotFoundError
43
43
  * ```
44
44
  */
45
- export function checkAndGetEnvValue(key: string): string {
45
+ export function checkAndGetEnvValue(key: string) {
46
46
  if (process.env[key] === undefined) throw new EnvironmentNotFoundError(key);
47
47
  return process.env[key];
48
48
  }
package/src/vue.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  useRoute,
6
6
  } from 'vue-router';
7
7
 
8
- import { appendRedirectParamToUrl } from './url';
8
+ import { appendRedirectParamToUrl } from '@/url';
9
9
 
10
10
  /**
11
11
  * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
package/src/web.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { appendRedirectParamToUrl } from './url';
1
+ import { appendRedirectParamToUrl } from '@/url';
2
2
 
3
3
  /**
4
4
  * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
package/dist/buffer.cjs DELETED
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- const node_buffer = require('node:buffer');
4
-
5
- /**
6
- * Converts a Blob, Buffer, or File to a Buffer.
7
- *
8
- * This function provides a unified way to convert various binary data types
9
- * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.
10
- * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.
11
- *
12
- * @param {Blob | Buffer | File} input - The input to convert to Buffer
13
- *
14
- * @returns {Promise<Buffer>} A Promise that resolves to a Buffer
15
- *
16
- * @example
17
- * ```typescript
18
- * import { toBuffer } from '@kikiutils/shared/general';
19
- *
20
- * // Convert a Buffer (returns as-is)
21
- * const buffer = Buffer.from('Hello World');
22
- * const result1 = await toBuffer(buffer);
23
- * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>
24
- *
25
- * // Convert a Blob
26
- * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });
27
- * const result2 = await toBuffer(blob);
28
- * console.log(result2.toString()); // 'Hello from Blob'
29
- *
30
- * // Convert a File
31
- * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });
32
- * const result3 = await toBuffer(file);
33
- * console.log(result3.toString()); // 'File content'
34
- * ```
35
- */
36
- async function toBuffer(input) {
37
- if (node_buffer.Buffer.isBuffer(input))
38
- return input;
39
- return node_buffer.Buffer.from(await input.arrayBuffer());
40
- }
41
-
42
- exports.toBuffer = toBuffer;
43
- //# sourceMappingURL=buffer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer.cjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type {\n Blob as NodeBlob,\n File as NodeFile,\n} from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":["Buffer"],"mappings":";;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,QAAQ,CAAC,KAAiD,EAAA;AAC5E,IAAA,IAAIA,kBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;IACxC,OAAOA,kBAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;AACjD;;;;"}
package/dist/buffer.mjs DELETED
@@ -1,41 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
-
3
- /**
4
- * Converts a Blob, Buffer, or File to a Buffer.
5
- *
6
- * This function provides a unified way to convert various binary data types
7
- * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.
8
- * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.
9
- *
10
- * @param {Blob | Buffer | File} input - The input to convert to Buffer
11
- *
12
- * @returns {Promise<Buffer>} A Promise that resolves to a Buffer
13
- *
14
- * @example
15
- * ```typescript
16
- * import { toBuffer } from '@kikiutils/shared/general';
17
- *
18
- * // Convert a Buffer (returns as-is)
19
- * const buffer = Buffer.from('Hello World');
20
- * const result1 = await toBuffer(buffer);
21
- * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>
22
- *
23
- * // Convert a Blob
24
- * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });
25
- * const result2 = await toBuffer(blob);
26
- * console.log(result2.toString()); // 'Hello from Blob'
27
- *
28
- * // Convert a File
29
- * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });
30
- * const result3 = await toBuffer(file);
31
- * console.log(result3.toString()); // 'File content'
32
- * ```
33
- */
34
- async function toBuffer(input) {
35
- if (Buffer.isBuffer(input))
36
- return input;
37
- return Buffer.from(await input.arrayBuffer());
38
- }
39
-
40
- export { toBuffer };
41
- //# sourceMappingURL=buffer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer.mjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type {\n Blob as NodeBlob,\n File as NodeFile,\n} from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":[],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,QAAQ,CAAC,KAAiD,EAAA;AAC5E,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;AACjD;;;;"}
@@ -1,91 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Attempts to copy a Blob (e.g. image, plain text, HTML) to the user's clipboard using the ClipboardItem API.
5
- *
6
- * ⚠️ Usage Notes:
7
- * - Must be called in a **secure context** (HTTPS or localhost).
8
- * - Must be called **in response to a user interaction** (e.g. click, input).
9
- * - Not supported in Safari and some older browsers.
10
- *
11
- * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content)
12
- * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor
13
- *
14
- * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
15
- * - `{ ok: true }` if the copy succeeded
16
- * - `{ ok: false, error }` if the copy failed, with the error included
17
- *
18
- * @example
19
- * ```typescript
20
- * import { copyBlobToClipboard } from '@kikiutils/shared/clipboard';
21
- *
22
- * const blob = new Blob(['Hello world'], { type: 'text/plain' });
23
- * const result = await copyBlobToClipboard(blob);
24
- * if (result.ok) {
25
- * console.log('Copied blob!');
26
- * } else {
27
- * console.error('Copy failed:', result.error);
28
- * }
29
- * ```
30
- */
31
- async function copyBlobToClipboard(blob, options) {
32
- if (!navigator.clipboard?.write) {
33
- return {
34
- error: new Error('Clipboard.write is not supported in this browser'),
35
- ok: false,
36
- };
37
- }
38
- try {
39
- const item = new ClipboardItem({ [blob.type]: blob }, options);
40
- await navigator.clipboard.write([item]);
41
- return { ok: true };
42
- }
43
- catch (error) {
44
- return {
45
- error,
46
- ok: false,
47
- };
48
- }
49
- }
50
- /**
51
- * Attempts to copy the given text to the user's clipboard using the modern Clipboard API.
52
- *
53
- * ⚠️ Usage Notes:
54
- * - Must be called in a **secure context** (HTTPS or localhost).
55
- * - Must be called **in response to a user interaction** (e.g. click, input).
56
- * - Not supported in some older browsers (especially legacy Safari).
57
- *
58
- * @param {string} text - The string to be copied to the clipboard
59
- *
60
- * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
61
- * - `{ ok: true }` if the copy succeeded
62
- * - `{ ok: false, error }` if the copy failed, with the error included
63
- *
64
- * @example
65
- * ```typescript
66
- * import { copyTextToClipboard } from '@kikiutils/shared/clipboard';
67
- *
68
- * const result = await copyTextToClipboard('Hello!');
69
- * if (result.ok) {
70
- * console.log('Copied!');
71
- * } else {
72
- * console.error('Copy failed:', result.error);
73
- * }
74
- * ```
75
- */
76
- async function copyTextToClipboard(text) {
77
- try {
78
- await navigator.clipboard.writeText(text);
79
- return { ok: true };
80
- }
81
- catch (error) {
82
- return {
83
- error,
84
- ok: false,
85
- };
86
- }
87
- }
88
-
89
- exports.copyBlobToClipboard = copyBlobToClipboard;
90
- exports.copyTextToClipboard = copyTextToClipboard;
91
- //# sourceMappingURL=clipboard.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clipboard.cjs","sources":["../src/clipboard.ts"],"sourcesContent":["type CopyResult =\n | { error: unknown; ok: false }\n | { ok: true };\n\n/**\n * Attempts to copy a Blob (e.g. image, plain text, HTML) to the user's clipboard using the ClipboardItem API.\n *\n * ⚠️ Usage Notes:\n * - Must be called in a **secure context** (HTTPS or localhost).\n * - Must be called **in response to a user interaction** (e.g. click, input).\n * - Not supported in Safari and some older browsers.\n *\n * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content)\n * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor\n *\n * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:\n * - `{ ok: true }` if the copy succeeded\n * - `{ ok: false, error }` if the copy failed, with the error included\n *\n * @example\n * ```typescript\n * import { copyBlobToClipboard } from '@kikiutils/shared/clipboard';\n *\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const result = await copyBlobToClipboard(blob);\n * if (result.ok) {\n * console.log('Copied blob!');\n * } else {\n * console.error('Copy failed:', result.error);\n * }\n * ```\n */\nexport async function copyBlobToClipboard(blob: Blob, options?: ClipboardItemOptions): Promise<CopyResult> {\n if (!navigator.clipboard?.write) {\n return {\n error: new Error('Clipboard.write is not supported in this browser'),\n ok: false,\n };\n }\n\n try {\n const item = new ClipboardItem({ [blob.type]: blob }, options);\n await navigator.clipboard.write([item]);\n return { ok: true };\n } catch (error) {\n return {\n error,\n ok: false,\n };\n }\n}\n\n/**\n * Attempts to copy the given text to the user's clipboard using the modern Clipboard API.\n *\n * ⚠️ Usage Notes:\n * - Must be called in a **secure context** (HTTPS or localhost).\n * - Must be called **in response to a user interaction** (e.g. click, input).\n * - Not supported in some older browsers (especially legacy Safari).\n *\n * @param {string} text - The string to be copied to the clipboard\n *\n * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:\n * - `{ ok: true }` if the copy succeeded\n * - `{ ok: false, error }` if the copy failed, with the error included\n *\n * @example\n * ```typescript\n * import { copyTextToClipboard } from '@kikiutils/shared/clipboard';\n *\n * const result = await copyTextToClipboard('Hello!');\n * if (result.ok) {\n * console.log('Copied!');\n * } else {\n * console.error('Copy failed:', result.error);\n * }\n * ```\n */\nexport async function copyTextToClipboard(text: string): Promise<CopyResult> {\n try {\n await navigator.clipboard.writeText(text);\n return { ok: true };\n } catch (error) {\n return {\n error,\n ok: false,\n };\n }\n}\n"],"names":[],"mappings":";;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,eAAe,mBAAmB,CAAC,IAAU,EAAE,OAA8B,EAAA;AAChF,IAAA,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE;QAC7B,OAAO;AACH,YAAA,KAAK,EAAE,IAAI,KAAK,CAAC,kDAAkD,CAAC;AACpE,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AAEA,IAAA,IAAI;AACA,QAAA,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC;QAC9D,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;AACvC,QAAA,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE;IACvB;IAAE,OAAO,KAAK,EAAE;QACZ,OAAO;YACH,KAAK;AACL,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AACJ;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACI,eAAe,mBAAmB,CAAC,IAAY,EAAA;AAClD,IAAA,IAAI;QACA,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;AACzC,QAAA,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE;IACvB;IAAE,OAAO,KAAK,EAAE;QACZ,OAAO;YACH,KAAK;AACL,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AACJ;;;;;"}
@@ -1,88 +0,0 @@
1
- /**
2
- * Attempts to copy a Blob (e.g. image, plain text, HTML) to the user's clipboard using the ClipboardItem API.
3
- *
4
- * ⚠️ Usage Notes:
5
- * - Must be called in a **secure context** (HTTPS or localhost).
6
- * - Must be called **in response to a user interaction** (e.g. click, input).
7
- * - Not supported in Safari and some older browsers.
8
- *
9
- * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content)
10
- * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor
11
- *
12
- * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
13
- * - `{ ok: true }` if the copy succeeded
14
- * - `{ ok: false, error }` if the copy failed, with the error included
15
- *
16
- * @example
17
- * ```typescript
18
- * import { copyBlobToClipboard } from '@kikiutils/shared/clipboard';
19
- *
20
- * const blob = new Blob(['Hello world'], { type: 'text/plain' });
21
- * const result = await copyBlobToClipboard(blob);
22
- * if (result.ok) {
23
- * console.log('Copied blob!');
24
- * } else {
25
- * console.error('Copy failed:', result.error);
26
- * }
27
- * ```
28
- */
29
- async function copyBlobToClipboard(blob, options) {
30
- if (!navigator.clipboard?.write) {
31
- return {
32
- error: new Error('Clipboard.write is not supported in this browser'),
33
- ok: false,
34
- };
35
- }
36
- try {
37
- const item = new ClipboardItem({ [blob.type]: blob }, options);
38
- await navigator.clipboard.write([item]);
39
- return { ok: true };
40
- }
41
- catch (error) {
42
- return {
43
- error,
44
- ok: false,
45
- };
46
- }
47
- }
48
- /**
49
- * Attempts to copy the given text to the user's clipboard using the modern Clipboard API.
50
- *
51
- * ⚠️ Usage Notes:
52
- * - Must be called in a **secure context** (HTTPS or localhost).
53
- * - Must be called **in response to a user interaction** (e.g. click, input).
54
- * - Not supported in some older browsers (especially legacy Safari).
55
- *
56
- * @param {string} text - The string to be copied to the clipboard
57
- *
58
- * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:
59
- * - `{ ok: true }` if the copy succeeded
60
- * - `{ ok: false, error }` if the copy failed, with the error included
61
- *
62
- * @example
63
- * ```typescript
64
- * import { copyTextToClipboard } from '@kikiutils/shared/clipboard';
65
- *
66
- * const result = await copyTextToClipboard('Hello!');
67
- * if (result.ok) {
68
- * console.log('Copied!');
69
- * } else {
70
- * console.error('Copy failed:', result.error);
71
- * }
72
- * ```
73
- */
74
- async function copyTextToClipboard(text) {
75
- try {
76
- await navigator.clipboard.writeText(text);
77
- return { ok: true };
78
- }
79
- catch (error) {
80
- return {
81
- error,
82
- ok: false,
83
- };
84
- }
85
- }
86
-
87
- export { copyBlobToClipboard, copyTextToClipboard };
88
- //# sourceMappingURL=clipboard.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clipboard.mjs","sources":["../src/clipboard.ts"],"sourcesContent":["type CopyResult =\n | { error: unknown; ok: false }\n | { ok: true };\n\n/**\n * Attempts to copy a Blob (e.g. image, plain text, HTML) to the user's clipboard using the ClipboardItem API.\n *\n * ⚠️ Usage Notes:\n * - Must be called in a **secure context** (HTTPS or localhost).\n * - Must be called **in response to a user interaction** (e.g. click, input).\n * - Not supported in Safari and some older browsers.\n *\n * @param {Blob} blob - The Blob object to copy (e.g. from a File, image, or text content)\n * @param {ClipboardItemOptions} [options] - Optional options passed to the ClipboardItem constructor\n *\n * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:\n * - `{ ok: true }` if the copy succeeded\n * - `{ ok: false, error }` if the copy failed, with the error included\n *\n * @example\n * ```typescript\n * import { copyBlobToClipboard } from '@kikiutils/shared/clipboard';\n *\n * const blob = new Blob(['Hello world'], { type: 'text/plain' });\n * const result = await copyBlobToClipboard(blob);\n * if (result.ok) {\n * console.log('Copied blob!');\n * } else {\n * console.error('Copy failed:', result.error);\n * }\n * ```\n */\nexport async function copyBlobToClipboard(blob: Blob, options?: ClipboardItemOptions): Promise<CopyResult> {\n if (!navigator.clipboard?.write) {\n return {\n error: new Error('Clipboard.write is not supported in this browser'),\n ok: false,\n };\n }\n\n try {\n const item = new ClipboardItem({ [blob.type]: blob }, options);\n await navigator.clipboard.write([item]);\n return { ok: true };\n } catch (error) {\n return {\n error,\n ok: false,\n };\n }\n}\n\n/**\n * Attempts to copy the given text to the user's clipboard using the modern Clipboard API.\n *\n * ⚠️ Usage Notes:\n * - Must be called in a **secure context** (HTTPS or localhost).\n * - Must be called **in response to a user interaction** (e.g. click, input).\n * - Not supported in some older browsers (especially legacy Safari).\n *\n * @param {string} text - The string to be copied to the clipboard\n *\n * @returns {Promise<CopyResult>} A promise resolving to a `CopyResult`:\n * - `{ ok: true }` if the copy succeeded\n * - `{ ok: false, error }` if the copy failed, with the error included\n *\n * @example\n * ```typescript\n * import { copyTextToClipboard } from '@kikiutils/shared/clipboard';\n *\n * const result = await copyTextToClipboard('Hello!');\n * if (result.ok) {\n * console.log('Copied!');\n * } else {\n * console.error('Copy failed:', result.error);\n * }\n * ```\n */\nexport async function copyTextToClipboard(text: string): Promise<CopyResult> {\n try {\n await navigator.clipboard.writeText(text);\n return { ok: true };\n } catch (error) {\n return {\n error,\n ok: false,\n };\n }\n}\n"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACI,eAAe,mBAAmB,CAAC,IAAU,EAAE,OAA8B,EAAA;AAChF,IAAA,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE;QAC7B,OAAO;AACH,YAAA,KAAK,EAAE,IAAI,KAAK,CAAC,kDAAkD,CAAC;AACpE,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AAEA,IAAA,IAAI;AACA,QAAA,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC;QAC9D,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;AACvC,QAAA,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE;IACvB;IAAE,OAAO,KAAK,EAAE;QACZ,OAAO;YACH,KAAK;AACL,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AACJ;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACI,eAAe,mBAAmB,CAAC,IAAY,EAAA;AAClD,IAAA,IAAI;QACA,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;AACzC,QAAA,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE;IACvB;IAAE,OAAO,KAAK,EAAE;QACZ,OAAO;YACH,KAAK;AACL,YAAA,EAAE,EAAE,KAAK;SACZ;IACL;AACJ;;;;"}
package/dist/consola.cjs DELETED
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- const consola = require('consola');
4
-
5
- /**
6
- * A consola logger instance.
7
- *
8
- * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables.
9
- * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,
10
- * the level will be set to `0`.
11
- *
12
- * To manually change the level, assign the desired level to `logger.level`.
13
- *
14
- * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level).
15
- *
16
- * @example
17
- * ```typescript
18
- * import { logger } from '@kikiutils/shared/consola';
19
- *
20
- * logger.info('test'); // ℹ test 3:56:30 AM
21
- *
22
- * // Manually change the level
23
- * logger.level = 3;
24
- * ```
25
- */
26
- const consolaLogger = consola.createConsola();
27
- const logger = consolaLogger;
28
- if (process.env.CONSOLA_LOGGER_LEVEL !== undefined)
29
- consolaLogger.level = +process.env.CONSOLA_LOGGER_LEVEL;
30
- else
31
- consolaLogger.level = process.env.NODE_ENV === 'production' ? 0 : consolaLogger.level;
32
-
33
- exports.consolaLogger = consolaLogger;
34
- exports.logger = logger;
35
- //# sourceMappingURL=consola.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consola.cjs","sources":["../src/consola.ts"],"sourcesContent":["import { createConsola } from 'consola';\n\n/**\n * A consola logger instance.\n *\n * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `0`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/consola';\n *\n * logger.info('test'); // ℹ test 3:56:30 AM\n *\n * // Manually change the level\n * logger.level = 3;\n * ```\n */\nexport const consolaLogger = createConsola();\nexport const logger = consolaLogger;\nif (process.env.CONSOLA_LOGGER_LEVEL !== undefined) consolaLogger.level = +process.env.CONSOLA_LOGGER_LEVEL;\nelse consolaLogger.level = process.env.NODE_ENV === 'production' ? 0 : consolaLogger.level;\n"],"names":["createConsola"],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,aAAa,GAAGA,qBAAa;AACnC,MAAM,MAAM,GAAG;AACtB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,SAAS;IAAE,aAAa,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB;;IACtG,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK;;;;;"}
package/dist/consola.mjs DELETED
@@ -1,32 +0,0 @@
1
- import { createConsola } from 'consola';
2
-
3
- /**
4
- * A consola logger instance.
5
- *
6
- * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables.
7
- * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,
8
- * the level will be set to `0`.
9
- *
10
- * To manually change the level, assign the desired level to `logger.level`.
11
- *
12
- * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level).
13
- *
14
- * @example
15
- * ```typescript
16
- * import { logger } from '@kikiutils/shared/consola';
17
- *
18
- * logger.info('test'); // ℹ test 3:56:30 AM
19
- *
20
- * // Manually change the level
21
- * logger.level = 3;
22
- * ```
23
- */
24
- const consolaLogger = createConsola();
25
- const logger = consolaLogger;
26
- if (process.env.CONSOLA_LOGGER_LEVEL !== undefined)
27
- consolaLogger.level = +process.env.CONSOLA_LOGGER_LEVEL;
28
- else
29
- consolaLogger.level = process.env.NODE_ENV === 'production' ? 0 : consolaLogger.level;
30
-
31
- export { consolaLogger, logger };
32
- //# sourceMappingURL=consola.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consola.mjs","sources":["../src/consola.ts"],"sourcesContent":["import { createConsola } from 'consola';\n\n/**\n * A consola logger instance.\n *\n * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables.\n * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,\n * the level will be set to `0`.\n *\n * To manually change the level, assign the desired level to `logger.level`.\n *\n * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level).\n *\n * @example\n * ```typescript\n * import { logger } from '@kikiutils/shared/consola';\n *\n * logger.info('test'); // ℹ test 3:56:30 AM\n *\n * // Manually change the level\n * logger.level = 3;\n * ```\n */\nexport const consolaLogger = createConsola();\nexport const logger = consolaLogger;\nif (process.env.CONSOLA_LOGGER_LEVEL !== undefined) consolaLogger.level = +process.env.CONSOLA_LOGGER_LEVEL;\nelse consolaLogger.level = process.env.NODE_ENV === 'production' ? 0 : consolaLogger.level;\n"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;AAoBG;AACI,MAAM,aAAa,GAAG,aAAa;AACnC,MAAM,MAAM,GAAG;AACtB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,SAAS;IAAE,aAAa,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB;;IACtG,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAG,CAAC,GAAG,aAAa,CAAC,KAAK;;;;"}
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- const node_crypto = require('node:crypto');
4
-
5
- /**
6
- * This file provides a set of functions for creating hash digests using different algorithms and bit lengths.
7
- * It includes functions for generating SHA-3 hash digests with bit lengths of 224, 256, 384, and 512,
8
- * as well as a function for generating MD5 hash digests.
9
- *
10
- * These functions use the Node.js crypto module to generate the hashes.
11
- * Can only be used in Node.js/Deno/Bun runtimes.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
16
- *
17
- * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
18
- * ```
19
- */
20
- function cryptoMd5(data, outputEncoding = 'hex') {
21
- return node_crypto.createHash('md5').update(data).digest(outputEncoding);
22
- }
23
- function cryptoMd5ToBuffer(data) {
24
- return node_crypto.createHash('md5').update(data).digest();
25
- }
26
- function cryptoSha3224(data, outputEncoding = 'hex') {
27
- return node_crypto.createHash('sha3-224').update(data).digest(outputEncoding);
28
- }
29
- function cryptoSha3224ToBuffer(data) {
30
- return node_crypto.createHash('sha3-224').update(data).digest();
31
- }
32
- function cryptoSha3256(data, outputEncoding = 'hex') {
33
- return node_crypto.createHash('sha3-256').update(data).digest(outputEncoding);
34
- }
35
- function cryptoSha3256ToBuffer(data) {
36
- return node_crypto.createHash('sha3-256').update(data).digest();
37
- }
38
- function cryptoSha3384(data, outputEncoding = 'hex') {
39
- return node_crypto.createHash('sha3-384').update(data).digest(outputEncoding);
40
- }
41
- function cryptoSha3384ToBuffer(data) {
42
- return node_crypto.createHash('sha3-384').update(data).digest();
43
- }
44
- function cryptoSha3512(data, outputEncoding = 'hex') {
45
- return node_crypto.createHash('sha3-512').update(data).digest(outputEncoding);
46
- }
47
- function cryptoSha3512ToBuffer(data) {
48
- return node_crypto.createHash('sha3-512').update(data).digest();
49
- }
50
-
51
- exports.cryptoMd5 = cryptoMd5;
52
- exports.cryptoMd5ToBuffer = cryptoMd5ToBuffer;
53
- exports.cryptoSha3224 = cryptoSha3224;
54
- exports.cryptoSha3224ToBuffer = cryptoSha3224ToBuffer;
55
- exports.cryptoSha3256 = cryptoSha3256;
56
- exports.cryptoSha3256ToBuffer = cryptoSha3256ToBuffer;
57
- exports.cryptoSha3384 = cryptoSha3384;
58
- exports.cryptoSha3384ToBuffer = cryptoSha3384ToBuffer;
59
- exports.cryptoSha3512 = cryptoSha3512;
60
- exports.cryptoSha3512ToBuffer = cryptoSha3512ToBuffer;
61
- //# sourceMappingURL=crypto-hash.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-hash.cjs","sources":["../src/crypto-hash.ts"],"sourcesContent":["/**\n * This file provides a set of functions for creating hash digests using different algorithms and bit lengths.\n * It includes functions for generating SHA-3 hash digests with bit lengths of 224, 256, 384, and 512,\n * as well as a function for generating MD5 hash digests.\n *\n * These functions use the Node.js crypto module to generate the hashes.\n * Can only be used in Node.js/Deno/Bun runtimes.\n *\n * @example\n * ```typescript\n * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\n\nimport { createHash } from 'node:crypto';\nimport type {\n BinaryLike,\n BinaryToTextEncoding,\n} from 'node:crypto';\n\nexport function cryptoMd5(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('md5').update(data).digest(outputEncoding);\n}\n\nexport function cryptoMd5ToBuffer(data: BinaryLike) {\n return createHash('md5').update(data).digest();\n}\n\nexport function cryptoSha3224(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-224').update(data).digest(outputEncoding);\n}\n\nexport function cryptoSha3224ToBuffer(data: BinaryLike) {\n return createHash('sha3-224').update(data).digest();\n}\n\nexport function cryptoSha3256(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-256').update(data).digest(outputEncoding);\n}\n\nexport function cryptoSha3256ToBuffer(data: BinaryLike) {\n return createHash('sha3-256').update(data).digest();\n}\n\nexport function cryptoSha3384(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-384').update(data).digest(outputEncoding);\n}\n\nexport function cryptoSha3384ToBuffer(data: BinaryLike) {\n return createHash('sha3-384').update(data).digest();\n}\n\nexport function cryptoSha3512(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-512').update(data).digest(outputEncoding);\n}\n\nexport function cryptoSha3512ToBuffer(data: BinaryLike) {\n return createHash('sha3-512').update(data).digest();\n}\n"],"names":["createHash"],"mappings":";;;;AAAA;;;;;;;;;;;;;;AAcG;SAQa,SAAS,CAAC,IAAgB,EAAE,iBAAuC,KAAK,EAAA;AACpF,IAAA,OAAOA,sBAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AAChE;AAEM,SAAU,iBAAiB,CAAC,IAAgB,EAAA;AAC9C,IAAA,OAAOA,sBAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AAClD;SAEgB,aAAa,CAAC,IAAgB,EAAE,iBAAuC,KAAK,EAAA;AACxF,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AACrE;AAEM,SAAU,qBAAqB,CAAC,IAAgB,EAAA;AAClD,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACvD;SAEgB,aAAa,CAAC,IAAgB,EAAE,iBAAuC,KAAK,EAAA;AACxF,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AACrE;AAEM,SAAU,qBAAqB,CAAC,IAAgB,EAAA;AAClD,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACvD;SAEgB,aAAa,CAAC,IAAgB,EAAE,iBAAuC,KAAK,EAAA;AACxF,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AACrE;AAEM,SAAU,qBAAqB,CAAC,IAAgB,EAAA;AAClD,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACvD;SAEgB,aAAa,CAAC,IAAgB,EAAE,iBAAuC,KAAK,EAAA;AACxF,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AACrE;AAEM,SAAU,qBAAqB,CAAC,IAAgB,EAAA;AAClD,IAAA,OAAOA,sBAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACvD;;;;;;;;;;;;;"}
@@ -1,50 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
-
3
- /**
4
- * This file provides a set of functions for creating hash digests using different algorithms and bit lengths.
5
- * It includes functions for generating SHA-3 hash digests with bit lengths of 224, 256, 384, and 512,
6
- * as well as a function for generating MD5 hash digests.
7
- *
8
- * These functions use the Node.js crypto module to generate the hashes.
9
- * Can only be used in Node.js/Deno/Bun runtimes.
10
- *
11
- * @example
12
- * ```typescript
13
- * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
14
- *
15
- * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
16
- * ```
17
- */
18
- function cryptoMd5(data, outputEncoding = 'hex') {
19
- return createHash('md5').update(data).digest(outputEncoding);
20
- }
21
- function cryptoMd5ToBuffer(data) {
22
- return createHash('md5').update(data).digest();
23
- }
24
- function cryptoSha3224(data, outputEncoding = 'hex') {
25
- return createHash('sha3-224').update(data).digest(outputEncoding);
26
- }
27
- function cryptoSha3224ToBuffer(data) {
28
- return createHash('sha3-224').update(data).digest();
29
- }
30
- function cryptoSha3256(data, outputEncoding = 'hex') {
31
- return createHash('sha3-256').update(data).digest(outputEncoding);
32
- }
33
- function cryptoSha3256ToBuffer(data) {
34
- return createHash('sha3-256').update(data).digest();
35
- }
36
- function cryptoSha3384(data, outputEncoding = 'hex') {
37
- return createHash('sha3-384').update(data).digest(outputEncoding);
38
- }
39
- function cryptoSha3384ToBuffer(data) {
40
- return createHash('sha3-384').update(data).digest();
41
- }
42
- function cryptoSha3512(data, outputEncoding = 'hex') {
43
- return createHash('sha3-512').update(data).digest(outputEncoding);
44
- }
45
- function cryptoSha3512ToBuffer(data) {
46
- return createHash('sha3-512').update(data).digest();
47
- }
48
-
49
- export { cryptoMd5, cryptoMd5ToBuffer, cryptoSha3224, cryptoSha3224ToBuffer, cryptoSha3256, cryptoSha3256ToBuffer, cryptoSha3384, cryptoSha3384ToBuffer, cryptoSha3512, cryptoSha3512ToBuffer };
50
- //# sourceMappingURL=crypto-hash.mjs.map