@kikiutils/shared 18.0.0 → 18.1.0

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 (156) hide show
  1. package/dist/buffer.d.ts +19 -21
  2. package/dist/buffer.d.ts.map +1 -1
  3. package/dist/buffer.js +18 -19
  4. package/dist/buffer.js.map +1 -1
  5. package/dist/classes/enhanced-date.d.ts +425 -0
  6. package/dist/classes/enhanced-date.d.ts.map +1 -0
  7. package/dist/classes/enhanced-date.js +591 -0
  8. package/dist/classes/enhanced-date.js.map +1 -0
  9. package/dist/classes/path.d.ts +211 -48
  10. package/dist/classes/path.d.ts.map +1 -1
  11. package/dist/classes/path.js +181 -52
  12. package/dist/classes/path.js.map +1 -1
  13. package/dist/classes/precision-number.d.ts +44 -39
  14. package/dist/classes/precision-number.d.ts.map +1 -1
  15. package/dist/classes/precision-number.js +51 -45
  16. package/dist/classes/precision-number.js.map +1 -1
  17. package/dist/classes/ssh-client.d.ts +3 -4
  18. package/dist/classes/ssh-client.d.ts.map +1 -1
  19. package/dist/classes/ssh-client.js +2 -2
  20. package/dist/classes/ssh-client.js.map +1 -1
  21. package/dist/clipboard.d.ts +25 -26
  22. package/dist/clipboard.d.ts.map +1 -1
  23. package/dist/clipboard.js +23 -23
  24. package/dist/clipboard.js.map +1 -1
  25. package/dist/consola.d.ts +12 -15
  26. package/dist/consola.d.ts.map +1 -1
  27. package/dist/consola.js +10 -12
  28. package/dist/consola.js.map +1 -1
  29. package/dist/crypto-hash.d.ts +65 -56
  30. package/dist/crypto-hash.d.ts.map +1 -1
  31. package/dist/crypto-hash.js +55 -45
  32. package/dist/crypto-hash.js.map +1 -1
  33. package/dist/datetime.d.ts +41 -53
  34. package/dist/datetime.d.ts.map +1 -1
  35. package/dist/datetime.js +53 -66
  36. package/dist/datetime.js.map +1 -1
  37. package/dist/element-plus.d.ts +13 -14
  38. package/dist/element-plus.d.ts.map +1 -1
  39. package/dist/element-plus.js +11 -11
  40. package/dist/element-plus.js.map +1 -1
  41. package/dist/enum.d.ts +39 -36
  42. package/dist/enum.d.ts.map +1 -1
  43. package/dist/enum.js +36 -32
  44. package/dist/enum.js.map +1 -1
  45. package/dist/env.d.ts +22 -15
  46. package/dist/env.d.ts.map +1 -1
  47. package/dist/env.js +20 -12
  48. package/dist/env.js.map +1 -1
  49. package/dist/event-awaiter.d.ts +47 -52
  50. package/dist/event-awaiter.d.ts.map +1 -1
  51. package/dist/event-awaiter.js +46 -50
  52. package/dist/event-awaiter.js.map +1 -1
  53. package/dist/general.d.ts +22 -17
  54. package/dist/general.d.ts.map +1 -1
  55. package/dist/general.js.map +1 -1
  56. package/dist/hash.d.ts +24 -21
  57. package/dist/hash.d.ts.map +1 -1
  58. package/dist/hash.js +20 -16
  59. package/dist/hash.js.map +1 -1
  60. package/dist/math.d.ts +20 -19
  61. package/dist/math.d.ts.map +1 -1
  62. package/dist/math.js +14 -12
  63. package/dist/math.js.map +1 -1
  64. package/dist/number.d.ts +10 -9
  65. package/dist/number.d.ts.map +1 -1
  66. package/dist/number.js +9 -7
  67. package/dist/number.js.map +1 -1
  68. package/dist/object.d.ts +22 -10
  69. package/dist/object.d.ts.map +1 -1
  70. package/dist/object.js +21 -8
  71. package/dist/object.js.map +1 -1
  72. package/dist/pino.d.ts +12 -15
  73. package/dist/pino.d.ts.map +1 -1
  74. package/dist/pino.js +10 -15
  75. package/dist/pino.js.map +1 -1
  76. package/dist/random.d.ts +17 -15
  77. package/dist/random.d.ts.map +1 -1
  78. package/dist/random.js +16 -13
  79. package/dist/random.js.map +1 -1
  80. package/dist/redis/script-runner.d.ts +57 -0
  81. package/dist/redis/script-runner.d.ts.map +1 -0
  82. package/dist/redis/script-runner.js +46 -0
  83. package/dist/redis/script-runner.js.map +1 -0
  84. package/dist/storages/lru/keyed-store.d.ts +18 -14
  85. package/dist/storages/lru/keyed-store.d.ts.map +1 -1
  86. package/dist/storages/lru/keyed-store.js +17 -12
  87. package/dist/storages/lru/keyed-store.js.map +1 -1
  88. package/dist/storages/redis/keyed-store.d.ts +11 -21
  89. package/dist/storages/redis/keyed-store.d.ts.map +1 -1
  90. package/dist/storages/redis/keyed-store.js +10 -19
  91. package/dist/storages/redis/keyed-store.js.map +1 -1
  92. package/dist/storages/redis/msgpack.d.ts +33 -13
  93. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  94. package/dist/storages/redis/msgpack.js +32 -11
  95. package/dist/storages/redis/msgpack.js.map +1 -1
  96. package/dist/storages/redis/types.d.ts +34 -17
  97. package/dist/storages/redis/types.d.ts.map +1 -1
  98. package/dist/string.d.ts +12 -11
  99. package/dist/string.d.ts.map +1 -1
  100. package/dist/string.js +20 -15
  101. package/dist/string.js.map +1 -1
  102. package/dist/time.d.ts +35 -10
  103. package/dist/time.d.ts.map +1 -1
  104. package/dist/time.js +49 -9
  105. package/dist/time.js.map +1 -1
  106. package/dist/types/filtered-key-path.d.ts +4 -15
  107. package/dist/types/filtered-key-path.d.ts.map +1 -1
  108. package/dist/types/index.d.ts +10 -10
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/vue.d.ts +7 -7
  111. package/dist/types/vue.d.ts.map +1 -1
  112. package/dist/url.d.ts +15 -14
  113. package/dist/url.d.ts.map +1 -1
  114. package/dist/url.js +12 -10
  115. package/dist/url.js.map +1 -1
  116. package/dist/vue.d.ts +19 -21
  117. package/dist/vue.d.ts.map +1 -1
  118. package/dist/vue.js +15 -16
  119. package/dist/vue.js.map +1 -1
  120. package/dist/web.d.ts +14 -11
  121. package/dist/web.d.ts.map +1 -1
  122. package/dist/web.js +12 -8
  123. package/dist/web.js.map +1 -1
  124. package/package.json +20 -20
  125. package/src/buffer.ts +18 -19
  126. package/src/classes/enhanced-date.ts +665 -0
  127. package/src/classes/path.ts +232 -91
  128. package/src/classes/precision-number.ts +61 -53
  129. package/src/classes/ssh-client.ts +8 -5
  130. package/src/clipboard.ts +23 -23
  131. package/src/consola.ts +10 -12
  132. package/src/crypto-hash.ts +55 -45
  133. package/src/datetime.ts +65 -85
  134. package/src/element-plus.ts +11 -11
  135. package/src/enum.ts +36 -32
  136. package/src/env.ts +20 -12
  137. package/src/event-awaiter.ts +49 -50
  138. package/src/general.ts +20 -14
  139. package/src/hash.ts +20 -16
  140. package/src/math.ts +18 -16
  141. package/src/number.ts +9 -7
  142. package/src/object.ts +21 -8
  143. package/src/pino.ts +11 -15
  144. package/src/random.ts +16 -13
  145. package/src/redis/script-runner.ts +107 -0
  146. package/src/storages/lru/keyed-store.ts +17 -12
  147. package/src/storages/redis/keyed-store.ts +10 -19
  148. package/src/storages/redis/msgpack.ts +32 -11
  149. package/src/storages/redis/types.ts +32 -14
  150. package/src/string.ts +10 -8
  151. package/src/time.ts +52 -8
  152. package/src/types/filtered-key-path.ts +9 -14
  153. package/src/types/vue.ts +6 -5
  154. package/src/url.ts +12 -10
  155. package/src/vue.ts +15 -16
  156. package/src/web.ts +12 -8
package/dist/consola.d.ts CHANGED
@@ -1,27 +1,24 @@
1
1
  //#region src/consola.d.ts
2
2
  /**
3
- * A consola logger instance.
3
+ * A consola logger with environment-controlled verbosity.
4
4
  *
5
- * The logger's level is determined based on the `CONSOLA_LOGGER_LEVEL` and `NODE_ENV` environment variables.
6
- * If `CONSOLA_LOGGER_LEVEL` is set, it will be used; otherwise, if `NODE_ENV` is `production`,
7
- * the level will be set to `0`.
8
- *
9
- * To manually change the level, assign the desired level to `logger.level`.
10
- *
11
- * See available levels [here](https://github.com/unjs/consola?tab=readme-ov-file#log-level).
5
+ * @remarks
6
+ * `CONSOLA_LOGGER_LEVEL` sets the log level when defined at module initialization;
7
+ * otherwise, `NODE_ENV=production` selects `0`, and other environments retain the logger's default level.
8
+ * Assign `logger.level` to change verbosity after initialization.
12
9
  *
13
10
  * @example
14
- * ```typescript
15
- * import { logger } from '@kikiutils/shared/consola';
16
11
  *
17
- * logger.info('test'); // ℹ test 3:56:30 AM
12
+ * ```ts
13
+ * import { logger } from '@kikiutils/shared/consola';
18
14
  *
19
- * // Manually change the level
20
15
  * logger.level = 3;
16
+ * logger.info('Application started');
21
17
  * ```
18
+ *
19
+ * @see {@link https://github.com/unjs/consola#log-level | Consola log levels}
22
20
  */
23
- declare const consolaLogger: import("consola").ConsolaInstance;
24
- declare const logger: import("consola").ConsolaInstance;
21
+ export declare const consolaLogger: import("consola").ConsolaInstance;
22
+ export declare const logger: import("consola").ConsolaInstance;
25
23
  //#endregion
26
- export { consolaLogger, logger };
27
24
  //# sourceMappingURL=consola.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consola.d.ts","names":[],"sources":["../src/consola.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;cAuBa,iCAAa;cACb,0BAAM"}
1
+ {"version":3,"file":"consola.d.ts","names":[],"sources":["../src/consola.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;qBAqBa,iCAAa;qBACb,0BAAM"}
package/dist/consola.js CHANGED
@@ -1,25 +1,23 @@
1
1
  import { createConsola } from "consola";
2
2
  //#region src/consola.ts
3
3
  /**
4
- * A consola logger instance.
4
+ * A consola logger with environment-controlled verbosity.
5
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).
6
+ * @remarks
7
+ * `CONSOLA_LOGGER_LEVEL` sets the log level when defined at module initialization;
8
+ * otherwise, `NODE_ENV=production` selects `0`, and other environments retain the logger's default level.
9
+ * Assign `logger.level` to change verbosity after initialization.
13
10
  *
14
11
  * @example
15
- * ```typescript
16
- * import { logger } from '@kikiutils/shared/consola';
17
12
  *
18
- * logger.info('test'); // ℹ test 3:56:30 AM
13
+ * ```ts
14
+ * import { logger } from '@kikiutils/shared/consola';
19
15
  *
20
- * // Manually change the level
21
16
  * logger.level = 3;
17
+ * logger.info('Application started');
22
18
  * ```
19
+ *
20
+ * @see {@link https://github.com/unjs/consola#log-level | Consola log levels}
23
21
  */
24
22
  const consolaLogger = createConsola();
25
23
  const logger = consolaLogger;
@@ -1 +1 @@
1
- {"version":3,"file":"consola.js","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAAgB,cAAc;AAC3C,MAAa,SAAS;AACtB,IAAI,QAAQ,IAAI,yBAAyB,KAAA,GAAW,cAAc,QAAQ,CAAC,QAAQ,IAAI;KAClF,cAAc,QAAQ,QAAQ,IAAI,aAAa,eAAe,IAAI,cAAc"}
1
+ {"version":3,"file":"consola.js","names":[],"sources":["../src/consola.ts"],"sourcesContent":["import { createConsola } from 'consola';\n\n/**\n * A consola logger with environment-controlled verbosity.\n *\n * @remarks\n * `CONSOLA_LOGGER_LEVEL` sets the log level when defined at module initialization;\n * otherwise, `NODE_ENV=production` selects `0`, and other environments retain the logger's default level.\n * Assign `logger.level` to change verbosity after initialization.\n *\n * @example\n *\n * ```ts\n * import { logger } from '@kikiutils/shared/consola';\n *\n * logger.level = 3;\n * logger.info('Application started');\n * ```\n *\n * @see {@link https://github.com/unjs/consola#log-level | Consola log levels}\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAgB,cAAc;AAC3C,MAAa,SAAS;AACtB,IAAI,QAAQ,IAAI,yBAAyB,KAAA,GAAW,cAAc,QAAQ,CAAC,QAAQ,IAAI;KAClF,cAAc,QAAQ,QAAQ,IAAI,aAAa,eAAe,IAAI,cAAc"}
@@ -3,158 +3,167 @@ import { BinaryLike } from "node:crypto";
3
3
  /**
4
4
  * Computes the MD5 hash of the given data.
5
5
  *
6
- * @param {BinaryLike} data - The input data to hash
7
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
6
+ * @param data - The input data to hash.
7
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
8
8
  *
9
- * @returns {string | Buffer} The hash digest in the specified encoding
9
+ * @returns The hash digest in the specified encoding.
10
10
  *
11
11
  * @example
12
- * ```typescript
12
+ *
13
+ * ```ts
13
14
  * import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';
14
15
  *
15
- * console.log(cryptoMd5('test')); // 098f6bcd4621d373cade4e832627b4f6
16
+ * console.log(cryptoMd5('test')); // => 098f6bcd4621d373cade4e832627b4f6
16
17
  * ```
17
18
  */
18
- declare function cryptoMd5(data: BinaryLike, outputEncoding?: BufferEncoding): string;
19
+ export declare function cryptoMd5(data: BinaryLike, outputEncoding?: BufferEncoding): string;
19
20
  /**
20
21
  * Computes the MD5 hash of the given data and returns the raw buffer.
21
22
  *
22
- * @param {BinaryLike} data - The input data to hash
23
+ * @param data - The input data to hash.
23
24
  *
24
- * @returns {Buffer} The raw hash digest as a Buffer
25
+ * @returns A new `Buffer` containing the raw hash digest.
25
26
  *
26
27
  * @example
27
- * ```typescript
28
+ *
29
+ * ```ts
28
30
  * import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';
29
31
  *
30
- * console.log(cryptoMd5ToBuffer('test')); // <Buffer 33 ed 9a ...>
32
+ * console.log(cryptoMd5ToBuffer('test')); // => <Buffer 09 8f 6b cd ...>
31
33
  * ```
32
34
  */
33
- declare function cryptoMd5ToBuffer(data: BinaryLike): NonSharedBuffer;
35
+ export declare function cryptoMd5ToBuffer(data: BinaryLike): NonSharedBuffer;
34
36
  /**
35
37
  * Computes the SHA-3 hash of the given data using the 224-bit digest.
36
38
  *
37
- * @param {BinaryLike} data - The input data to hash
38
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
39
+ * @param data - The input data to hash.
40
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
39
41
  *
40
- * @returns {string | Buffer} The hash digest in the specified encoding
42
+ * @returns The hash digest in the specified encoding.
41
43
  *
42
44
  * @example
43
- * ```typescript
45
+ *
46
+ * ```ts
44
47
  * import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';
45
48
  *
46
- * console.log(cryptoSha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
49
+ * console.log(cryptoSha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
47
50
  * ```
48
51
  */
49
- declare function cryptoSha3224(data: BinaryLike, outputEncoding?: BufferEncoding): string;
52
+ export declare function cryptoSha3224(data: BinaryLike, outputEncoding?: BufferEncoding): string;
50
53
  /**
51
54
  * Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.
52
55
  *
53
- * @param {BinaryLike} data - The input data to hash
56
+ * @param data - The input data to hash.
54
57
  *
55
- * @returns {Buffer} The raw hash digest as a Buffer
58
+ * @returns A new `Buffer` containing the raw hash digest.
56
59
  *
57
60
  * @example
58
- * ```typescript
61
+ *
62
+ * ```ts
59
63
  * import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';
60
64
  *
61
- * console.log(cryptoSha3224ToBuffer('test')); // <Buffer 37 97 bf 0a ...>
65
+ * console.log(cryptoSha3224ToBuffer('test')); // => <Buffer 37 97 bf 0a ...>
62
66
  * ```
63
67
  */
64
- declare function cryptoSha3224ToBuffer(data: BinaryLike): NonSharedBuffer;
68
+ export declare function cryptoSha3224ToBuffer(data: BinaryLike): NonSharedBuffer;
65
69
  /**
66
70
  * Computes the SHA-3 hash of the given data using the 256-bit digest.
67
71
  *
68
- * @param {BinaryLike} data - The input data to hash
69
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
72
+ * @param data - The input data to hash.
73
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
70
74
  *
71
- * @returns {string | Buffer} The hash digest in the specified encoding
75
+ * @returns The hash digest in the specified encoding.
72
76
  *
73
77
  * @example
74
- * ```typescript
78
+ *
79
+ * ```ts
75
80
  * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
76
81
  *
77
- * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
82
+ * console.log(cryptoSha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
78
83
  * ```
79
84
  */
80
- declare function cryptoSha3256(data: BinaryLike, outputEncoding?: BufferEncoding): string;
85
+ export declare function cryptoSha3256(data: BinaryLike, outputEncoding?: BufferEncoding): string;
81
86
  /**
82
87
  * Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.
83
88
  *
84
- * @param {BinaryLike} data - The input data to hash
89
+ * @param data - The input data to hash.
85
90
  *
86
- * @returns {Buffer} The raw hash digest as a Buffer
91
+ * @returns A new `Buffer` containing the raw hash digest.
87
92
  *
88
93
  * @example
89
- * ```typescript
94
+ *
95
+ * ```ts
90
96
  * import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';
91
97
  *
92
- * console.log(cryptoSha3256ToBuffer('test')); // <Buffer 36 f0 28 ...>
98
+ * console.log(cryptoSha3256ToBuffer('test')); // => <Buffer 36 f0 28 ...>
93
99
  * ```
94
100
  */
95
- declare function cryptoSha3256ToBuffer(data: BinaryLike): NonSharedBuffer;
101
+ export declare function cryptoSha3256ToBuffer(data: BinaryLike): NonSharedBuffer;
96
102
  /**
97
103
  * Computes the SHA-3 hash of the given data using the 384-bit digest.
98
104
  *
99
- * @param {BinaryLike} data - The input data to hash
100
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
105
+ * @param data - The input data to hash.
106
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
101
107
  *
102
- * @returns {string | Buffer} The hash digest in the specified encoding
108
+ * @returns The hash digest in the specified encoding.
103
109
  *
104
110
  * @example
105
- * ```typescript
111
+ *
112
+ * ```ts
106
113
  * import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';
107
114
  *
108
- * console.log(cryptoSha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
115
+ * console.log(cryptoSha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
109
116
  * ```
110
117
  */
111
- declare function cryptoSha3384(data: BinaryLike, outputEncoding?: BufferEncoding): string;
118
+ export declare function cryptoSha3384(data: BinaryLike, outputEncoding?: BufferEncoding): string;
112
119
  /**
113
120
  * Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.
114
121
  *
115
- * @param {BinaryLike} data - The input data to hash
122
+ * @param data - The input data to hash.
116
123
  *
117
- * @returns {Buffer} The raw hash digest as a Buffer
124
+ * @returns A new `Buffer` containing the raw hash digest.
118
125
  *
119
126
  * @example
120
- * ```typescript
127
+ *
128
+ * ```ts
121
129
  * import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';
122
130
  *
123
- * console.log(cryptoSha3384ToBuffer('test')); // <Buffer e5 16 da bb ...>
131
+ * console.log(cryptoSha3384ToBuffer('test')); // => <Buffer e5 16 da bb ...>
124
132
  * ```
125
133
  */
126
- declare function cryptoSha3384ToBuffer(data: BinaryLike): NonSharedBuffer;
134
+ export declare function cryptoSha3384ToBuffer(data: BinaryLike): NonSharedBuffer;
127
135
  /**
128
136
  * Computes the SHA-3 hash of the given data using the 512-bit digest.
129
137
  *
130
- * @param {BinaryLike} data - The input data to hash
131
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
138
+ * @param data - The input data to hash.
139
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
132
140
  *
133
- * @returns {string | Buffer} The hash digest in the specified encoding
141
+ * @returns The hash digest in the specified encoding.
134
142
  *
135
143
  * @example
136
- * ```typescript
144
+ *
145
+ * ```ts
137
146
  * import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';
138
147
  *
139
- * console.log(cryptoSha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
148
+ * console.log(cryptoSha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
140
149
  * ```
141
150
  */
142
- declare function cryptoSha3512(data: BinaryLike, outputEncoding?: BufferEncoding): string;
151
+ export declare function cryptoSha3512(data: BinaryLike, outputEncoding?: BufferEncoding): string;
143
152
  /**
144
153
  * Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.
145
154
  *
146
- * @param {BinaryLike} data - The input data to hash
155
+ * @param data - The input data to hash.
147
156
  *
148
- * @returns {Buffer} The raw hash digest as a Buffer
157
+ * @returns A new `Buffer` containing the raw hash digest.
149
158
  *
150
159
  * @example
151
- * ```typescript
160
+ *
161
+ * ```ts
152
162
  * import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';
153
163
  *
154
- * console.log(cryptoSha3512ToBuffer('test')); // <Buffer 9e ce 08 6e ...>
164
+ * console.log(cryptoSha3512ToBuffer('test')); // => <Buffer 9e ce 08 6e ...>
155
165
  * ```
156
166
  */
157
- declare function cryptoSha3512ToBuffer(data: BinaryLike): NonSharedBuffer;
167
+ export declare function cryptoSha3512ToBuffer(data: BinaryLike): NonSharedBuffer;
158
168
  //#endregion
159
- export { cryptoMd5, cryptoMd5ToBuffer, cryptoSha3224, cryptoSha3224ToBuffer, cryptoSha3256, cryptoSha3256ToBuffer, cryptoSha3384, cryptoSha3384ToBuffer, cryptoSha3512, cryptoSha3512ToBuffer };
160
169
  //# sourceMappingURL=crypto-hash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-hash.d.ts","names":[],"sources":["../src/crypto-hash.ts"],"mappings":";;;;;;;;;;;;;;;;;iBAmBgB,UAAU,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;iBAkB5C,kBAAkB,MAAM,aAAU;;;;;;;;;;;;;;;;iBAmBlC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;iBAkBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;iBAmBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;iBAkBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;iBAmBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;iBAkBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;iBAmBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;iBAkBhD,sBAAsB,MAAM,aAAU"}
1
+ {"version":3,"file":"crypto-hash.d.ts","names":[],"sources":["../src/crypto-hash.ts"],"mappings":";;;;;;;;;;;;;;;;;;wBAoBgB,UAAU,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;;wBAmB5C,kBAAkB,MAAM,aAAU;;;;;;;;;;;;;;;;;wBAoBlC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;;wBAmBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;;wBAoBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;;wBAmBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;;wBAoBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;;wBAmBhD,sBAAsB,MAAM,aAAU;;;;;;;;;;;;;;;;;wBAoBtC,cAAc,MAAM,YAAY,iBAAgB;;;;;;;;;;;;;;;;wBAmBhD,sBAAsB,MAAM,aAAU"}
@@ -4,16 +4,17 @@ import { createHash } from "node:crypto";
4
4
  /**
5
5
  * Computes the MD5 hash of the given data.
6
6
  *
7
- * @param {BinaryLike} data - The input data to hash
8
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
7
+ * @param data - The input data to hash.
8
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
9
9
  *
10
- * @returns {string | Buffer} The hash digest in the specified encoding
10
+ * @returns The hash digest in the specified encoding.
11
11
  *
12
12
  * @example
13
- * ```typescript
13
+ *
14
+ * ```ts
14
15
  * import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';
15
16
  *
16
- * console.log(cryptoMd5('test')); // 098f6bcd4621d373cade4e832627b4f6
17
+ * console.log(cryptoMd5('test')); // => 098f6bcd4621d373cade4e832627b4f6
17
18
  * ```
18
19
  */
19
20
  function cryptoMd5(data, outputEncoding = "hex") {
@@ -22,15 +23,16 @@ function cryptoMd5(data, outputEncoding = "hex") {
22
23
  /**
23
24
  * Computes the MD5 hash of the given data and returns the raw buffer.
24
25
  *
25
- * @param {BinaryLike} data - The input data to hash
26
+ * @param data - The input data to hash.
26
27
  *
27
- * @returns {Buffer} The raw hash digest as a Buffer
28
+ * @returns A new `Buffer` containing the raw hash digest.
28
29
  *
29
30
  * @example
30
- * ```typescript
31
+ *
32
+ * ```ts
31
33
  * import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';
32
34
  *
33
- * console.log(cryptoMd5ToBuffer('test')); // <Buffer 33 ed 9a ...>
35
+ * console.log(cryptoMd5ToBuffer('test')); // => <Buffer 09 8f 6b cd ...>
34
36
  * ```
35
37
  */
36
38
  function cryptoMd5ToBuffer(data) {
@@ -39,16 +41,17 @@ function cryptoMd5ToBuffer(data) {
39
41
  /**
40
42
  * Computes the SHA-3 hash of the given data using the 224-bit digest.
41
43
  *
42
- * @param {BinaryLike} data - The input data to hash
43
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
44
+ * @param data - The input data to hash.
45
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
44
46
  *
45
- * @returns {string | Buffer} The hash digest in the specified encoding
47
+ * @returns The hash digest in the specified encoding.
46
48
  *
47
49
  * @example
48
- * ```typescript
50
+ *
51
+ * ```ts
49
52
  * import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';
50
53
  *
51
- * console.log(cryptoSha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
54
+ * console.log(cryptoSha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
52
55
  * ```
53
56
  */
54
57
  function cryptoSha3224(data, outputEncoding = "hex") {
@@ -57,15 +60,16 @@ function cryptoSha3224(data, outputEncoding = "hex") {
57
60
  /**
58
61
  * Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.
59
62
  *
60
- * @param {BinaryLike} data - The input data to hash
63
+ * @param data - The input data to hash.
61
64
  *
62
- * @returns {Buffer} The raw hash digest as a Buffer
65
+ * @returns A new `Buffer` containing the raw hash digest.
63
66
  *
64
67
  * @example
65
- * ```typescript
68
+ *
69
+ * ```ts
66
70
  * import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';
67
71
  *
68
- * console.log(cryptoSha3224ToBuffer('test')); // <Buffer 37 97 bf 0a ...>
72
+ * console.log(cryptoSha3224ToBuffer('test')); // => <Buffer 37 97 bf 0a ...>
69
73
  * ```
70
74
  */
71
75
  function cryptoSha3224ToBuffer(data) {
@@ -74,16 +78,17 @@ function cryptoSha3224ToBuffer(data) {
74
78
  /**
75
79
  * Computes the SHA-3 hash of the given data using the 256-bit digest.
76
80
  *
77
- * @param {BinaryLike} data - The input data to hash
78
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
81
+ * @param data - The input data to hash.
82
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
79
83
  *
80
- * @returns {string | Buffer} The hash digest in the specified encoding
84
+ * @returns The hash digest in the specified encoding.
81
85
  *
82
86
  * @example
83
- * ```typescript
87
+ *
88
+ * ```ts
84
89
  * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
85
90
  *
86
- * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
91
+ * console.log(cryptoSha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
87
92
  * ```
88
93
  */
89
94
  function cryptoSha3256(data, outputEncoding = "hex") {
@@ -92,15 +97,16 @@ function cryptoSha3256(data, outputEncoding = "hex") {
92
97
  /**
93
98
  * Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.
94
99
  *
95
- * @param {BinaryLike} data - The input data to hash
100
+ * @param data - The input data to hash.
96
101
  *
97
- * @returns {Buffer} The raw hash digest as a Buffer
102
+ * @returns A new `Buffer` containing the raw hash digest.
98
103
  *
99
104
  * @example
100
- * ```typescript
105
+ *
106
+ * ```ts
101
107
  * import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';
102
108
  *
103
- * console.log(cryptoSha3256ToBuffer('test')); // <Buffer 36 f0 28 ...>
109
+ * console.log(cryptoSha3256ToBuffer('test')); // => <Buffer 36 f0 28 ...>
104
110
  * ```
105
111
  */
106
112
  function cryptoSha3256ToBuffer(data) {
@@ -109,16 +115,17 @@ function cryptoSha3256ToBuffer(data) {
109
115
  /**
110
116
  * Computes the SHA-3 hash of the given data using the 384-bit digest.
111
117
  *
112
- * @param {BinaryLike} data - The input data to hash
113
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
118
+ * @param data - The input data to hash.
119
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
114
120
  *
115
- * @returns {string | Buffer} The hash digest in the specified encoding
121
+ * @returns The hash digest in the specified encoding.
116
122
  *
117
123
  * @example
118
- * ```typescript
124
+ *
125
+ * ```ts
119
126
  * import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';
120
127
  *
121
- * console.log(cryptoSha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
128
+ * console.log(cryptoSha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
122
129
  * ```
123
130
  */
124
131
  function cryptoSha3384(data, outputEncoding = "hex") {
@@ -127,15 +134,16 @@ function cryptoSha3384(data, outputEncoding = "hex") {
127
134
  /**
128
135
  * Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.
129
136
  *
130
- * @param {BinaryLike} data - The input data to hash
137
+ * @param data - The input data to hash.
131
138
  *
132
- * @returns {Buffer} The raw hash digest as a Buffer
139
+ * @returns A new `Buffer` containing the raw hash digest.
133
140
  *
134
141
  * @example
135
- * ```typescript
142
+ *
143
+ * ```ts
136
144
  * import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';
137
145
  *
138
- * console.log(cryptoSha3384ToBuffer('test')); // <Buffer e5 16 da bb ...>
146
+ * console.log(cryptoSha3384ToBuffer('test')); // => <Buffer e5 16 da bb ...>
139
147
  * ```
140
148
  */
141
149
  function cryptoSha3384ToBuffer(data) {
@@ -144,16 +152,17 @@ function cryptoSha3384ToBuffer(data) {
144
152
  /**
145
153
  * Computes the SHA-3 hash of the given data using the 512-bit digest.
146
154
  *
147
- * @param {BinaryLike} data - The input data to hash
148
- * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
155
+ * @param data - The input data to hash.
156
+ * @param outputEncoding - The output encoding. Defaults to `hex`.
149
157
  *
150
- * @returns {string | Buffer} The hash digest in the specified encoding
158
+ * @returns The hash digest in the specified encoding.
151
159
  *
152
160
  * @example
153
- * ```typescript
161
+ *
162
+ * ```ts
154
163
  * import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';
155
164
  *
156
- * console.log(cryptoSha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
165
+ * console.log(cryptoSha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
157
166
  * ```
158
167
  */
159
168
  function cryptoSha3512(data, outputEncoding = "hex") {
@@ -162,15 +171,16 @@ function cryptoSha3512(data, outputEncoding = "hex") {
162
171
  /**
163
172
  * Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.
164
173
  *
165
- * @param {BinaryLike} data - The input data to hash
174
+ * @param data - The input data to hash.
166
175
  *
167
- * @returns {Buffer} The raw hash digest as a Buffer
176
+ * @returns A new `Buffer` containing the raw hash digest.
168
177
  *
169
178
  * @example
170
- * ```typescript
179
+ *
180
+ * ```ts
171
181
  * import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';
172
182
  *
173
- * console.log(cryptoSha3512ToBuffer('test')); // <Buffer 9e ce 08 6e ...>
183
+ * console.log(cryptoSha3512ToBuffer('test')); // => <Buffer 9e ce 08 6e ...>
174
184
  * ```
175
185
  */
176
186
  function cryptoSha3512ToBuffer(data) {
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-hash.js","names":[],"sources":["../src/crypto-hash.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { createHash } from 'node:crypto';\nimport type { BinaryLike } from 'node:crypto';\n\n/**\n * Computes the MD5 hash of the given data.\n *\n * @param {BinaryLike} data - The input data to hash\n * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)\n *\n * @returns {string | Buffer} The hash digest in the specified encoding\n *\n * @example\n * ```typescript\n * import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoMd5('test')); // 098f6bcd4621d373cade4e832627b4f6\n * ```\n */\nexport function cryptoMd5(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('md5').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the MD5 hash of the given data and returns the raw buffer.\n *\n * @param {BinaryLike} data - The input data to hash\n *\n * @returns {Buffer} The raw hash digest as a Buffer\n *\n * @example\n * ```typescript\n * import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoMd5ToBuffer('test')); // <Buffer 33 ed 9a ...>\n * ```\n */\nexport function cryptoMd5ToBuffer(data: BinaryLike) {\n return createHash('md5').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest.\n *\n * @param {BinaryLike} data - The input data to hash\n * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)\n *\n * @returns {string | Buffer} The hash digest in the specified encoding\n *\n * @example\n * ```typescript\n * import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b\n * ```\n */\nexport function cryptoSha3224(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-224').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.\n *\n * @param {BinaryLike} data - The input data to hash\n *\n * @returns {Buffer} The raw hash digest as a Buffer\n *\n * @example\n * ```typescript\n * import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3224ToBuffer('test')); // <Buffer 37 97 bf 0a ...>\n * ```\n */\nexport function cryptoSha3224ToBuffer(data: BinaryLike) {\n return createHash('sha3-224').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 256-bit digest.\n *\n * @param {BinaryLike} data - The input data to hash\n * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)\n *\n * @returns {string | Buffer} The hash digest in the specified encoding\n *\n * @example\n * ```typescript\n * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\nexport function cryptoSha3256(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-256').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.\n *\n * @param {BinaryLike} data - The input data to hash\n *\n * @returns {Buffer} The raw hash digest as a Buffer\n *\n * @example\n * ```typescript\n * import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3256ToBuffer('test')); // <Buffer 36 f0 28 ...>\n * ```\n */\nexport function cryptoSha3256ToBuffer(data: BinaryLike) {\n return createHash('sha3-256').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 384-bit digest.\n *\n * @param {BinaryLike} data - The input data to hash\n * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)\n *\n * @returns {string | Buffer} The hash digest in the specified encoding\n *\n * @example\n * ```typescript\n * import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...\n * ```\n */\nexport function cryptoSha3384(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-384').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.\n *\n * @param {BinaryLike} data - The input data to hash\n *\n * @returns {Buffer} The raw hash digest as a Buffer\n *\n * @example\n * ```typescript\n * import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3384ToBuffer('test')); // <Buffer e5 16 da bb ...>\n * ```\n */\nexport function cryptoSha3384ToBuffer(data: BinaryLike) {\n return createHash('sha3-384').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 512-bit digest.\n *\n * @param {BinaryLike} data - The input data to hash\n * @param {BufferEncoding} [outputEncoding] - The output encoding (default: `'hex'`)\n *\n * @returns {string | Buffer} The hash digest in the specified encoding\n *\n * @example\n * ```typescript\n * import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...\n * ```\n */\nexport function cryptoSha3512(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-512').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.\n *\n * @param {BinaryLike} data - The input data to hash\n *\n * @returns {Buffer} The raw hash digest as a Buffer\n *\n * @example\n * ```typescript\n * import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3512ToBuffer('test')); // <Buffer 9e ce 08 6e ...>\n * ```\n */\nexport function cryptoSha3512ToBuffer(data: BinaryLike) {\n return createHash('sha3-512').update(normalizeHashData(data)).digest();\n}\n\nfunction normalizeHashData(data: BinaryLike): NodeJS.ArrayBufferView | string {\n return typeof data === 'string' || ArrayBuffer.isView(data) ? data : Buffer.from(data);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAAgB,UAAU,MAAkB,iBAAiC,OAAO;CAChF,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AAClF;;;;;;;;;;;;;;;AAgBA,SAAgB,kBAAkB,MAAkB;CAChD,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACpE;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;AAgBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;AAgBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;AAgBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;AAgBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;AAEA,SAAS,kBAAkB,MAAmD;CAC1E,OAAO,OAAO,SAAS,YAAY,YAAY,OAAO,IAAI,IAAI,OAAO,OAAO,KAAK,IAAI;AACzF"}
1
+ {"version":3,"file":"crypto-hash.js","names":[],"sources":["../src/crypto-hash.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { createHash } from 'node:crypto';\nimport type { BinaryLike } from 'node:crypto';\n\n/**\n * Computes the MD5 hash of the given data.\n *\n * @param data - The input data to hash.\n * @param outputEncoding - The output encoding. Defaults to `hex`.\n *\n * @returns The hash digest in the specified encoding.\n *\n * @example\n *\n * ```ts\n * import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoMd5('test')); // => 098f6bcd4621d373cade4e832627b4f6\n * ```\n */\nexport function cryptoMd5(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('md5').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the MD5 hash of the given data and returns the raw buffer.\n *\n * @param data - The input data to hash.\n *\n * @returns A new `Buffer` containing the raw hash digest.\n *\n * @example\n *\n * ```ts\n * import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoMd5ToBuffer('test')); // => <Buffer 09 8f 6b cd ...>\n * ```\n */\nexport function cryptoMd5ToBuffer(data: BinaryLike) {\n return createHash('md5').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest.\n *\n * @param data - The input data to hash.\n * @param outputEncoding - The output encoding. Defaults to `hex`.\n *\n * @returns The hash digest in the specified encoding.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3224('test')); // => 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b\n * ```\n */\nexport function cryptoSha3224(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-224').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.\n *\n * @param data - The input data to hash.\n *\n * @returns A new `Buffer` containing the raw hash digest.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3224ToBuffer('test')); // => <Buffer 37 97 bf 0a ...>\n * ```\n */\nexport function cryptoSha3224ToBuffer(data: BinaryLike) {\n return createHash('sha3-224').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 256-bit digest.\n *\n * @param data - The input data to hash.\n * @param outputEncoding - The output encoding. Defaults to `hex`.\n *\n * @returns The hash digest in the specified encoding.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3256('test')); // => 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80\n * ```\n */\nexport function cryptoSha3256(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-256').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.\n *\n * @param data - The input data to hash.\n *\n * @returns A new `Buffer` containing the raw hash digest.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3256ToBuffer('test')); // => <Buffer 36 f0 28 ...>\n * ```\n */\nexport function cryptoSha3256ToBuffer(data: BinaryLike) {\n return createHash('sha3-256').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 384-bit digest.\n *\n * @param data - The input data to hash.\n * @param outputEncoding - The output encoding. Defaults to `hex`.\n *\n * @returns The hash digest in the specified encoding.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3384('test')); // => e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...\n * ```\n */\nexport function cryptoSha3384(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-384').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.\n *\n * @param data - The input data to hash.\n *\n * @returns A new `Buffer` containing the raw hash digest.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3384ToBuffer('test')); // => <Buffer e5 16 da bb ...>\n * ```\n */\nexport function cryptoSha3384ToBuffer(data: BinaryLike) {\n return createHash('sha3-384').update(normalizeHashData(data)).digest();\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 512-bit digest.\n *\n * @param data - The input data to hash.\n * @param outputEncoding - The output encoding. Defaults to `hex`.\n *\n * @returns The hash digest in the specified encoding.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3512('test')); // => 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...\n * ```\n */\nexport function cryptoSha3512(data: BinaryLike, outputEncoding: BufferEncoding = 'hex') {\n return createHash('sha3-512').update(normalizeHashData(data)).digest(outputEncoding);\n}\n\n/**\n * Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.\n *\n * @param data - The input data to hash.\n *\n * @returns A new `Buffer` containing the raw hash digest.\n *\n * @example\n *\n * ```ts\n * import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';\n *\n * console.log(cryptoSha3512ToBuffer('test')); // => <Buffer 9e ce 08 6e ...>\n * ```\n */\nexport function cryptoSha3512ToBuffer(data: BinaryLike) {\n return createHash('sha3-512').update(normalizeHashData(data)).digest();\n}\n\nfunction normalizeHashData(data: BinaryLike): NodeJS.ArrayBufferView | string {\n return typeof data === 'string' || ArrayBuffer.isView(data) ? data : Buffer.from(data);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,UAAU,MAAkB,iBAAiC,OAAO;CAChF,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AAClF;;;;;;;;;;;;;;;;AAiBA,SAAgB,kBAAkB,MAAkB;CAChD,OAAO,WAAW,KAAK,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACpE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,cAAc,MAAkB,iBAAiC,OAAO;CACpF,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO,cAAc;AACvF;;;;;;;;;;;;;;;;AAiBA,SAAgB,sBAAsB,MAAkB;CACpD,OAAO,WAAW,UAAU,CAAC,CAAC,OAAO,kBAAkB,IAAI,CAAC,CAAC,CAAC,OAAO;AACzE;AAEA,SAAS,kBAAkB,MAAmD;CAC1E,OAAO,OAAO,SAAS,YAAY,YAAY,OAAO,IAAI,IAAI,OAAO,OAAO,KAAK,IAAI;AACzF"}