@kikiutils/shared 15.0.0 → 15.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -119
- package/dist/classes/ssh-client.d.ts +3 -3
- package/dist/classes/ssh-client.d.ts.map +1 -1
- package/dist/consola.d.ts +3 -3
- package/dist/consola.d.ts.map +1 -1
- package/dist/crypto-hash.d.ts +145 -0
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +137 -7
- package/dist/crypto-hash.js.map +1 -1
- package/dist/datetime.d.ts +0 -2
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +0 -2
- package/dist/datetime.js.map +1 -1
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +2 -0
- package/dist/env.js.map +1 -1
- package/dist/event-awaiter.js +1 -1
- package/dist/event-awaiter.js.map +1 -1
- package/dist/hash.d.ts +48 -5
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +49 -6
- package/dist/hash.js.map +1 -1
- package/dist/math.js +1 -1
- package/dist/math.js.map +1 -1
- package/dist/object.d.ts +4 -0
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +4 -0
- package/dist/object.js.map +1 -1
- package/dist/pino.d.ts +3 -3
- package/dist/random.js +2 -0
- package/dist/random.js.map +1 -1
- package/dist/storages/lru/keyed-store.d.ts +22 -0
- package/dist/storages/lru/keyed-store.d.ts.map +1 -1
- package/dist/storages/lru/keyed-store.js +22 -0
- package/dist/storages/lru/keyed-store.js.map +1 -1
- package/dist/storages/redis/keyed-store.d.ts +25 -0
- package/dist/storages/redis/keyed-store.d.ts.map +1 -1
- package/dist/storages/redis/keyed-store.js +25 -0
- package/dist/storages/redis/keyed-store.js.map +1 -1
- package/dist/storages/redis/msgpack.d.ts +20 -0
- package/dist/storages/redis/msgpack.d.ts.map +1 -1
- package/dist/storages/redis/msgpack.js +20 -0
- package/dist/storages/redis/msgpack.js.map +1 -1
- package/dist/storages/redis/types.d.ts +42 -0
- package/dist/storages/redis/types.d.ts.map +1 -1
- package/dist/string.js +1 -1
- package/dist/string.js.map +1 -1
- package/dist/time.d.ts +17 -0
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +17 -0
- package/dist/time.js.map +1 -1
- package/dist/url.d.ts +3 -0
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +8 -2
- package/dist/url.js.map +1 -1
- package/dist/vue.d.ts +6 -0
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +6 -0
- package/dist/vue.js.map +1 -1
- package/package.json +22 -22
- package/src/crypto-hash.ts +143 -14
- package/src/datetime.ts +0 -2
- package/src/env.ts +2 -0
- package/src/event-awaiter.ts +1 -1
- package/src/hash.ts +56 -14
- package/src/math.ts +2 -1
- package/src/object.ts +4 -0
- package/src/random.ts +3 -0
- package/src/storages/lru/keyed-store.ts +22 -0
- package/src/storages/redis/keyed-store.ts +25 -0
- package/src/storages/redis/msgpack.ts +20 -0
- package/src/storages/redis/types.ts +52 -0
- package/src/string.ts +1 -1
- package/src/time.ts +17 -0
- package/src/url.ts +13 -2
- package/src/vue.ts +6 -0
package/README.md
CHANGED
|
@@ -9,8 +9,6 @@ A lightweight and modular utility library for modern JavaScript and TypeScript
|
|
|
9
9
|
|
|
10
10
|
- [✨ Release Notes](./CHANGELOG.md)
|
|
11
11
|
|
|
12
|
-
TODO: update README
|
|
13
|
-
|
|
14
12
|
## Features
|
|
15
13
|
|
|
16
14
|
- 📋 Clipboard utilities — copy text and blobs using the modern Clipboard API (Browser only)
|
|
@@ -47,17 +45,58 @@ You can also use `yarn`, `npm`, or `bun`.
|
|
|
47
45
|
>
|
|
48
46
|
> If a utility depends on a third-party package (e.g. `date-fns`), you must install it manually.
|
|
49
47
|
|
|
50
|
-
##
|
|
48
|
+
## Modules
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
```
|
|
51
|
+
src/
|
|
52
|
+
├── classes/ # Class-based utilities
|
|
53
|
+
│ ├── path.ts # Path manipulation
|
|
54
|
+
│ ├── precision-number.ts # Decimal.js wrapper
|
|
55
|
+
│ └── ssh-client.ts # SSH client
|
|
56
|
+
│
|
|
57
|
+
├── storages/
|
|
58
|
+
│ ├── lru/keyed-store.ts # LRU cache wrapper
|
|
59
|
+
│ └── redis/
|
|
60
|
+
│ ├── keyed-store.ts # Redis keyed store
|
|
61
|
+
│ ├── msgpack.ts # Redis + msgpack
|
|
62
|
+
│ └── types.ts # Storage interfaces
|
|
63
|
+
│
|
|
64
|
+
└── *.ts # Utility functions (see table)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| File | Description |
|
|
68
|
+
|------|-------------|
|
|
69
|
+
| `buffer.ts` | Binary → Node.js Buffer |
|
|
70
|
+
| `clipboard.ts` | Clipboard API (browser) |
|
|
71
|
+
| `consola.ts` | Consola logger |
|
|
72
|
+
| `crypto-hash.ts` | MD5, SHA3 (Node) |
|
|
73
|
+
| `datetime.ts` | date-fns wrappers |
|
|
74
|
+
| `element-plus.ts` | Element Plus form rules |
|
|
75
|
+
| `enum.ts` | Enum value extractors |
|
|
76
|
+
| `env.ts` | Env var accessor |
|
|
77
|
+
| `event-awaiter.ts` | Async event wait |
|
|
78
|
+
| `general.ts` | extractFirstValue |
|
|
79
|
+
| `hash.ts` | SHA3 (browser) |
|
|
80
|
+
| `math.ts` | toPercentageString |
|
|
81
|
+
| `number.ts` | toCompactNumberString |
|
|
82
|
+
| `object.ts` | deterministic stringify |
|
|
83
|
+
| `pino.ts` | Pino logger |
|
|
84
|
+
| `random.ts` | nested random length |
|
|
85
|
+
| `string.ts` | randomString |
|
|
86
|
+
| `time.ts` | abortableDelay |
|
|
87
|
+
| `url.ts` | redirect param |
|
|
88
|
+
| `vue.ts` | Vue composables |
|
|
89
|
+
| `web.ts` | Web DOM helpers |
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
53
92
|
|
|
54
93
|
```typescript
|
|
55
|
-
import { logger } from '@
|
|
56
|
-
import { extractFirstValue } from '@
|
|
94
|
+
import { logger } from '@kikiutils/shared/consola';
|
|
95
|
+
import { extractFirstValue } from '@kikiutils/shared/general';
|
|
57
96
|
|
|
58
97
|
const data = [
|
|
59
98
|
0,
|
|
60
|
-
1
|
|
99
|
+
1,
|
|
61
100
|
];
|
|
62
101
|
|
|
63
102
|
const value = extractFirstValue(data);
|
|
@@ -65,118 +104,6 @@ console.log(value); // 0
|
|
|
65
104
|
logger.info(value);
|
|
66
105
|
```
|
|
67
106
|
|
|
68
|
-
## Modules & Functions
|
|
69
|
-
|
|
70
|
-
Each module file includes function-level comments and usage examples.
|
|
71
|
-
|
|
72
|
-
### [buffer](./src/buffer.ts)
|
|
73
|
-
|
|
74
|
-
- `toBuffer`
|
|
75
|
-
|
|
76
|
-
### [clipboard](./src/clipboard.ts)
|
|
77
|
-
|
|
78
|
-
- `copyBlobToClipboard`
|
|
79
|
-
- `copyTextToClipboard`
|
|
80
|
-
|
|
81
|
-
### [consola](./src/consola.ts)
|
|
82
|
-
|
|
83
|
-
Console logger integration.
|
|
84
|
-
|
|
85
|
-
### [crypto-hash](./src/crypto-hash.ts)
|
|
86
|
-
|
|
87
|
-
- `cryptoMd5`, `cryptoMd5ToBuffer`
|
|
88
|
-
- `cryptoSha3224`, `cryptoSha3224ToBuffer`
|
|
89
|
-
- `cryptoSha3256`, `cryptoSha3256ToBuffer`
|
|
90
|
-
- `cryptoSha3384`, `cryptoSha3384ToBuffer`
|
|
91
|
-
- `cryptoSha3512`, `cryptoSha3512ToBuffer`
|
|
92
|
-
|
|
93
|
-
### [datetime](./src/datetime.ts)
|
|
94
|
-
|
|
95
|
-
- `formatDate`
|
|
96
|
-
- `getDateRangeFromDate`
|
|
97
|
-
- `getMidnightDateFromToday`
|
|
98
|
-
|
|
99
|
-
### [element-plus](./src/element-plus.ts)
|
|
100
|
-
|
|
101
|
-
- `createElFormItemRuleWithDefaults`
|
|
102
|
-
|
|
103
|
-
### [enum](./src/enum.ts)
|
|
104
|
-
|
|
105
|
-
- `getEnumStringValues`
|
|
106
|
-
- `getEnumNumberValues`
|
|
107
|
-
- `getEnumValues`
|
|
108
|
-
|
|
109
|
-
### [env](./src/env.ts)
|
|
110
|
-
|
|
111
|
-
- `checkAndGetEnvValue`
|
|
112
|
-
|
|
113
|
-
### [general](./src/general.ts)
|
|
114
|
-
|
|
115
|
-
- `extractFirstValue`
|
|
116
|
-
|
|
117
|
-
### [hash](./src/hash.ts)
|
|
118
|
-
|
|
119
|
-
- `sha3224`
|
|
120
|
-
- `sha3256`
|
|
121
|
-
- `sha3384`
|
|
122
|
-
- `sha3512`
|
|
123
|
-
|
|
124
|
-
### [math](./src/math.ts)
|
|
125
|
-
|
|
126
|
-
- `toPercentageString`
|
|
127
|
-
|
|
128
|
-
### [number](./src/number.ts)
|
|
129
|
-
|
|
130
|
-
- `toCompactNumberString`
|
|
131
|
-
|
|
132
|
-
### [object](./src/object.ts)
|
|
133
|
-
|
|
134
|
-
- `stringifyObjectDeterministically`
|
|
135
|
-
|
|
136
|
-
### [pino](./src/pino.ts)
|
|
137
|
-
|
|
138
|
-
Pino logger integration.
|
|
139
|
-
|
|
140
|
-
### [random](./src/random.ts)
|
|
141
|
-
|
|
142
|
-
- `generateWithNestedRandomLength`
|
|
143
|
-
|
|
144
|
-
### storage
|
|
145
|
-
|
|
146
|
-
#### [enhanced-local](./src/storage/enhanced/local/index.ts)
|
|
147
|
-
|
|
148
|
-
- `createKeyedEnhancedLocalStore`
|
|
149
|
-
- `enhancedLocalStorage`
|
|
150
|
-
|
|
151
|
-
#### [enhanced-redis](./src/storage/enhanced/redis/index.ts)
|
|
152
|
-
|
|
153
|
-
- `createEnhancedRedisStorage`
|
|
154
|
-
- `createKeyedEnhancedRedisStore`
|
|
155
|
-
|
|
156
|
-
#### [lru/keyed-store](./src/storage/lru/keyed-store.ts)
|
|
157
|
-
|
|
158
|
-
- `createKeyedLruStore`
|
|
159
|
-
|
|
160
|
-
### [string](./src/string.ts)
|
|
161
|
-
|
|
162
|
-
- `randomString`
|
|
163
|
-
|
|
164
|
-
### [url](./src/url.ts)
|
|
165
|
-
|
|
166
|
-
- `appendRedirectParamToUrl`
|
|
167
|
-
|
|
168
|
-
### [vue](./src/vue.ts)
|
|
169
|
-
|
|
170
|
-
- `appendRedirectParamFromCurrentRouteToUrl`
|
|
171
|
-
- `clearIntervalRef`
|
|
172
|
-
- `clearTimeoutRef`
|
|
173
|
-
- `usePreserveScroll`
|
|
174
|
-
|
|
175
|
-
### [web](./src/web.ts)
|
|
176
|
-
|
|
177
|
-
- `appendRedirectParamFromCurrentLocationToUrl`
|
|
178
|
-
- `assignUrlWithRedirectParamFromCurrentLocation`
|
|
179
|
-
|
|
180
107
|
## License
|
|
181
108
|
|
|
182
109
|
[MIT License](./LICENSE)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Nullable } from "../types/index.js";
|
|
2
2
|
import { PathLike } from "./path.js";
|
|
3
|
-
import * as node_ssh0 from "node-ssh";
|
|
3
|
+
import * as _$node_ssh0 from "node-ssh";
|
|
4
4
|
import { Config, NodeSSH, SSHExecCommandOptions, SSHGetPutDirectoryOptions, SSHPutFilesOptions } from "node-ssh";
|
|
5
5
|
import { SFTPWrapper, TransferOptions } from "ssh2";
|
|
6
6
|
|
|
@@ -22,8 +22,8 @@ declare class SshClient {
|
|
|
22
22
|
get nodeSsh(): NodeSSH;
|
|
23
23
|
connect(): Promise<boolean>;
|
|
24
24
|
disconnect(): boolean;
|
|
25
|
-
execCommand(command: string, options?: SSHExecCommandOptions): Promise<void | node_ssh0.SSHExecCommandResponse>;
|
|
26
|
-
execCommandWithIo(command: string, options?: SSHExecCommandOptions): Promise<void | node_ssh0.SSHExecCommandResponse>;
|
|
25
|
+
execCommand(command: string, options?: SSHExecCommandOptions): Promise<void | _$node_ssh0.SSHExecCommandResponse>;
|
|
26
|
+
execCommandWithIo(command: string, options?: SSHExecCommandOptions): Promise<void | _$node_ssh0.SSHExecCommandResponse>;
|
|
27
27
|
getDir: (localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions) => Promise<boolean>;
|
|
28
28
|
getDirectory(localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions): Promise<boolean>;
|
|
29
29
|
getFile(localFile: PathLike, remoteFile: PathLike, givenSftp?: Nullable<SFTPWrapper>, transferOptions?: Nullable<TransferOptions>): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-client.d.ts","names":[],"sources":["../../src/classes/ssh-client.ts"],"mappings":";;;;;;;cAkBM,qCAAA;EAAA;;;;;;;;;;cAYO,SAAA;EAAA;cAMG,IAAA,UAAc,QAAA,UAAkB,QAAA,UAAkB,IAAA,WAAmB,aAAA,GAAgB,MAAA;EAAA,IAc7F,OAAA,CAAA,GAAO,OAAA;EAIL,OAAA,CAAA,GAAO,OAAA;EAUb,UAAA,CAAA;EAUA,WAAA,CAAY,OAAA,UAAiB,OAAA,GAAU,qBAAA,GAAqB,OAAA,QAAA,
|
|
1
|
+
{"version":3,"file":"ssh-client.d.ts","names":[],"sources":["../../src/classes/ssh-client.ts"],"mappings":";;;;;;;cAkBM,qCAAA;EAAA;;;;;;;;;;cAYO,SAAA;EAAA;cAMG,IAAA,UAAc,QAAA,UAAkB,QAAA,UAAkB,IAAA,WAAmB,aAAA,GAAgB,MAAA;EAAA,IAc7F,OAAA,CAAA,GAAO,OAAA;EAIL,OAAA,CAAA,GAAO,OAAA;EAUb,UAAA,CAAA;EAUA,WAAA,CAAY,OAAA,UAAiB,OAAA,GAAU,qBAAA,GAAqB,OAAA,QAAA,WAAA,CAAA,sBAAA;EAI5D,iBAAA,CAAkB,OAAA,UAAiB,OAAA,GAAU,qBAAA,GAAqB,OAAA,QAAA,WAAA,CAAA,sBAAA;EAWlE,MAAA,GAAM,cAAA,EAE6B,QAAA,EAAQ,eAAA,EAAmB,QAAA,EAAQ,OAAA,GAAY,yBAAA,KAAyB,OAAA;EAArG,YAAA,CAAa,cAAA,EAAgB,QAAA,EAAU,eAAA,EAAiB,QAAA,EAAU,OAAA,GAAU,yBAAA,GAAyB,OAAA;EASrG,OAAA,CACF,SAAA,EAAW,QAAA,EACX,UAAA,EAAY,QAAA,EACZ,SAAA,GAAY,QAAA,CAAS,WAAA,GACrB,eAAA,GAAkB,QAAA,CAAS,eAAA,IAAgB,OAAA;EAW/C,WAAA,CAAA;EAIM,KAAA,CAAM,IAAA,EAAM,QAAA,GAAQ,OAAA;EAU1B,MAAA,GAAM,cAAA,EAE6B,QAAA,EAAQ,eAAA,EAAmB,QAAA,EAAQ,OAAA,GAAY,yBAAA,KAAyB,OAAA;EAArG,YAAA,CAAa,cAAA,EAAgB,QAAA,EAAU,eAAA,EAAiB,QAAA,EAAU,OAAA,GAAU,yBAAA,GAAyB,OAAA;EASrG,OAAA,CACF,SAAA,EAAW,QAAA,EACX,UAAA,EAAY,QAAA,EACZ,SAAA,GAAY,QAAA,CAAS,WAAA,GACrB,eAAA,GAAkB,QAAA,CAAS,eAAA,IAAgB,OAAA;EAWzC,QAAA,CAAS,KAAA;IAAS,KAAA,EAAO,QAAA;IAAU,MAAA,EAAQ,QAAA;EAAA,KAAc,OAAA,GAAU,kBAAA,GAAkB,OAAA;EAe3F,cAAA,CAAe,KAAA,eAAoB,qCAAA;AAAA"}
|
package/dist/consola.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as consola from "consola";
|
|
1
|
+
import * as _$consola from "consola";
|
|
2
2
|
|
|
3
3
|
//#region src/consola.d.ts
|
|
4
4
|
/**
|
|
@@ -22,8 +22,8 @@ import * as consola from "consola";
|
|
|
22
22
|
* logger.level = 3;
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
declare const consolaLogger: consola.ConsolaInstance;
|
|
26
|
-
declare const logger: consola.ConsolaInstance;
|
|
25
|
+
declare const consolaLogger: _$consola.ConsolaInstance;
|
|
26
|
+
declare const logger: _$consola.ConsolaInstance;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { consolaLogger, logger };
|
|
29
29
|
//# sourceMappingURL=consola.d.ts.map
|
package/dist/consola.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consola.d.ts","names":[],"sources":["../src/consola.ts"],"mappings":";;;;;;AAuBA;;;;;AACA;;;;;;;;;;;;;cADa,aAAA,EAA+B,
|
|
1
|
+
{"version":3,"file":"consola.d.ts","names":[],"sources":["../src/consola.ts"],"mappings":";;;;;;AAuBA;;;;;AACA;;;;;;;;;;;;;cADa,aAAA,EAA+B,SAAA,CAAlB,eAAA;AAAA,cACb,MAAA,EAAsB,SAAA,CAAhB,eAAA"}
|
package/dist/crypto-hash.d.ts
CHANGED
|
@@ -1,15 +1,160 @@
|
|
|
1
1
|
import { BinaryLike, BinaryToTextEncoding } from "node:crypto";
|
|
2
2
|
|
|
3
3
|
//#region src/crypto-hash.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Computes the MD5 hash of the given data.
|
|
6
|
+
*
|
|
7
|
+
* @param {BinaryLike} data - The input data to hash
|
|
8
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
9
|
+
*
|
|
10
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';
|
|
15
|
+
*
|
|
16
|
+
* console.log(cryptoMd5('test')); // 33ed9a05a10b21f0...
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
declare function cryptoMd5(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
20
|
+
/**
|
|
21
|
+
* Computes the MD5 hash of the given data and returns the raw buffer.
|
|
22
|
+
*
|
|
23
|
+
* @param {BinaryLike} data - The input data to hash
|
|
24
|
+
*
|
|
25
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
30
|
+
*
|
|
31
|
+
* console.log(cryptoMd5ToBuffer('test')); // <Buffer 33 ed 9a ...>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
5
34
|
declare function cryptoMd5ToBuffer(data: BinaryLike): NonSharedBuffer;
|
|
35
|
+
/**
|
|
36
|
+
* Computes the SHA-3 hash of the given data using the 224-bit digest.
|
|
37
|
+
*
|
|
38
|
+
* @param {BinaryLike} data - The input data to hash
|
|
39
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
40
|
+
*
|
|
41
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';
|
|
46
|
+
*
|
|
47
|
+
* console.log(cryptoSha3224('test')); // 0qW8FoqDcFmkpuqR9J3uT8YX...
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
6
50
|
declare function cryptoSha3224(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
51
|
+
/**
|
|
52
|
+
* Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.
|
|
53
|
+
*
|
|
54
|
+
* @param {BinaryLike} data - The input data to hash
|
|
55
|
+
*
|
|
56
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
61
|
+
*
|
|
62
|
+
* console.log(cryptoSha3224ToBuffer('test')); // <Buffer 0q W8 Fo ...>
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
7
65
|
declare function cryptoSha3224ToBuffer(data: BinaryLike): NonSharedBuffer;
|
|
66
|
+
/**
|
|
67
|
+
* Computes the SHA-3 hash of the given data using the 256-bit digest.
|
|
68
|
+
*
|
|
69
|
+
* @param {BinaryLike} data - The input data to hash
|
|
70
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
71
|
+
*
|
|
72
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
|
|
77
|
+
*
|
|
78
|
+
* console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
8
81
|
declare function cryptoSha3256(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
82
|
+
/**
|
|
83
|
+
* Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.
|
|
84
|
+
*
|
|
85
|
+
* @param {BinaryLike} data - The input data to hash
|
|
86
|
+
*
|
|
87
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
92
|
+
*
|
|
93
|
+
* console.log(cryptoSha3256ToBuffer('test')); // <Buffer 36 f0 28 ...>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
9
96
|
declare function cryptoSha3256ToBuffer(data: BinaryLike): NonSharedBuffer;
|
|
97
|
+
/**
|
|
98
|
+
* Computes the SHA-3 hash of the given data using the 384-bit digest.
|
|
99
|
+
*
|
|
100
|
+
* @param {BinaryLike} data - The input data to hash
|
|
101
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
102
|
+
*
|
|
103
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';
|
|
108
|
+
*
|
|
109
|
+
* console.log(cryptoSha3384('test')); // 1Q2wQAYaZ4o8vWX5bEB2n3Y...
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
10
112
|
declare function cryptoSha3384(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
113
|
+
/**
|
|
114
|
+
* Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.
|
|
115
|
+
*
|
|
116
|
+
* @param {BinaryLike} data - The input data to hash
|
|
117
|
+
*
|
|
118
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
123
|
+
*
|
|
124
|
+
* console.log(cryptoSha3384ToBuffer('test')); // <Buffer 1Q 2w QZ ...>
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
11
127
|
declare function cryptoSha3384ToBuffer(data: BinaryLike): NonSharedBuffer;
|
|
128
|
+
/**
|
|
129
|
+
* Computes the SHA-3 hash of the given data using the 512-bit digest.
|
|
130
|
+
*
|
|
131
|
+
* @param {BinaryLike} data - The input data to hash
|
|
132
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
133
|
+
*
|
|
134
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';
|
|
139
|
+
*
|
|
140
|
+
* console.log(cryptoSha3512('test')); // b_NQJ8FJBY9dIjm1q7...
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
12
143
|
declare function cryptoSha3512(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
|
|
144
|
+
/**
|
|
145
|
+
* Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.
|
|
146
|
+
*
|
|
147
|
+
* @param {BinaryLike} data - The input data to hash
|
|
148
|
+
*
|
|
149
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
154
|
+
*
|
|
155
|
+
* console.log(cryptoSha3512ToBuffer('test')); // <Buffer b_ NQ ...>
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
13
158
|
declare function cryptoSha3512ToBuffer(data: BinaryLike): NonSharedBuffer;
|
|
14
159
|
//#endregion
|
|
15
160
|
export { cryptoMd5, cryptoMd5ToBuffer, cryptoSha3224, cryptoSha3224ToBuffer, cryptoSha3256, cryptoSha3256ToBuffer, cryptoSha3384, cryptoSha3384ToBuffer, cryptoSha3512, cryptoSha3512ToBuffer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-hash.d.ts","names":[],"sources":["../src/crypto-hash.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"crypto-hash.d.ts","names":[],"sources":["../src/crypto-hash.ts"],"mappings":";;;;;AAqBA;;;;;;;;;;AAkBA;;;iBAlBgB,SAAA,CAAU,IAAA,EAAM,UAAA,EAAY,cAAA,GAAgB,oBAAA;;;;;;AAqC5D;;;;;;;;;iBAnBgB,iBAAA,CAAkB,IAAA,EAAM,UAAA,GAAU,eAAA;AAqClD;;;;;;;;;AAmBA;;;;;;AAnBA,iBAlBgB,aAAA,CAAc,IAAA,EAAM,UAAA,EAAY,cAAA,GAAgB,oBAAA;;;;AAuDhE;;;;;;;;;AAmBA;;iBAxDgB,qBAAA,CAAsB,IAAA,EAAM,UAAA,GAAU,eAAA;;;;;;;;AA0EtD;;;;;;;;iBAvDgB,aAAA,CAAc,IAAA,EAAM,UAAA,EAAY,cAAA,GAAgB,oBAAA;AA0EhE;;;;;;;;;;AAkBA;;;;AAlBA,iBAxDgB,qBAAA,CAAsB,IAAA,EAAM,UAAA,GAAU,eAAA;;;;;;;;;;;;;;;;iBAmBtC,aAAA,CAAc,IAAA,EAAM,UAAA,EAAY,cAAA,GAAgB,oBAAA;;;;;;;;;;;;;;;iBAkBhD,qBAAA,CAAsB,IAAA,EAAM,UAAA,GAAU,eAAA;;;;;;;;;;;;;;;;iBAmBtC,aAAA,CAAc,IAAA,EAAM,UAAA,EAAY,cAAA,GAAgB,oBAAA;;;;;;;;;;;;;;;iBAkBhD,qBAAA,CAAsB,IAAA,EAAM,UAAA,GAAU,eAAA"}
|
package/dist/crypto-hash.js
CHANGED
|
@@ -1,47 +1,177 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
//#region src/crypto-hash.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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.
|
|
4
|
+
* Computes the MD5 hash of the given data.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* @param {BinaryLike} data - The input data to hash
|
|
7
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
8
|
+
*
|
|
9
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
|
-
* import {
|
|
13
|
+
* import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';
|
|
14
14
|
*
|
|
15
|
-
* console.log(
|
|
15
|
+
* console.log(cryptoMd5('test')); // 33ed9a05a10b21f0...
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
function cryptoMd5(data, outputEncoding = "hex") {
|
|
19
19
|
return createHash("md5").update(data).digest(outputEncoding);
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Computes the MD5 hash of the given data and returns the raw buffer.
|
|
23
|
+
*
|
|
24
|
+
* @param {BinaryLike} data - The input data to hash
|
|
25
|
+
*
|
|
26
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { cryptoMd5ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
31
|
+
*
|
|
32
|
+
* console.log(cryptoMd5ToBuffer('test')); // <Buffer 33 ed 9a ...>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
21
35
|
function cryptoMd5ToBuffer(data) {
|
|
22
36
|
return createHash("md5").update(data).digest();
|
|
23
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Computes the SHA-3 hash of the given data using the 224-bit digest.
|
|
40
|
+
*
|
|
41
|
+
* @param {BinaryLike} data - The input data to hash
|
|
42
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
43
|
+
*
|
|
44
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';
|
|
49
|
+
*
|
|
50
|
+
* console.log(cryptoSha3224('test')); // 0qW8FoqDcFmkpuqR9J3uT8YX...
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
24
53
|
function cryptoSha3224(data, outputEncoding = "hex") {
|
|
25
54
|
return createHash("sha3-224").update(data).digest(outputEncoding);
|
|
26
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Computes the SHA-3 hash of the given data using the 224-bit digest and returns the raw buffer.
|
|
58
|
+
*
|
|
59
|
+
* @param {BinaryLike} data - The input data to hash
|
|
60
|
+
*
|
|
61
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
66
|
+
*
|
|
67
|
+
* console.log(cryptoSha3224ToBuffer('test')); // <Buffer 0q W8 Fo ...>
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
27
70
|
function cryptoSha3224ToBuffer(data) {
|
|
28
71
|
return createHash("sha3-224").update(data).digest();
|
|
29
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Computes the SHA-3 hash of the given data using the 256-bit digest.
|
|
75
|
+
*
|
|
76
|
+
* @param {BinaryLike} data - The input data to hash
|
|
77
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
78
|
+
*
|
|
79
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { cryptoSha3256 } from '@kikiutils/shared/crypto-hash';
|
|
84
|
+
*
|
|
85
|
+
* console.log(cryptoSha3256('test')); // 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
30
88
|
function cryptoSha3256(data, outputEncoding = "hex") {
|
|
31
89
|
return createHash("sha3-256").update(data).digest(outputEncoding);
|
|
32
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Computes the SHA-3 hash of the given data using the 256-bit digest and returns the raw buffer.
|
|
93
|
+
*
|
|
94
|
+
* @param {BinaryLike} data - The input data to hash
|
|
95
|
+
*
|
|
96
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* import { cryptoSha3256ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
101
|
+
*
|
|
102
|
+
* console.log(cryptoSha3256ToBuffer('test')); // <Buffer 36 f0 28 ...>
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
33
105
|
function cryptoSha3256ToBuffer(data) {
|
|
34
106
|
return createHash("sha3-256").update(data).digest();
|
|
35
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Computes the SHA-3 hash of the given data using the 384-bit digest.
|
|
110
|
+
*
|
|
111
|
+
* @param {BinaryLike} data - The input data to hash
|
|
112
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
113
|
+
*
|
|
114
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';
|
|
119
|
+
*
|
|
120
|
+
* console.log(cryptoSha3384('test')); // 1Q2wQAYaZ4o8vWX5bEB2n3Y...
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
36
123
|
function cryptoSha3384(data, outputEncoding = "hex") {
|
|
37
124
|
return createHash("sha3-384").update(data).digest(outputEncoding);
|
|
38
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Computes the SHA-3 hash of the given data using the 384-bit digest and returns the raw buffer.
|
|
128
|
+
*
|
|
129
|
+
* @param {BinaryLike} data - The input data to hash
|
|
130
|
+
*
|
|
131
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
136
|
+
*
|
|
137
|
+
* console.log(cryptoSha3384ToBuffer('test')); // <Buffer 1Q 2w QZ ...>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
39
140
|
function cryptoSha3384ToBuffer(data) {
|
|
40
141
|
return createHash("sha3-384").update(data).digest();
|
|
41
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Computes the SHA-3 hash of the given data using the 512-bit digest.
|
|
145
|
+
*
|
|
146
|
+
* @param {BinaryLike} data - The input data to hash
|
|
147
|
+
* @param {BinaryToTextEncoding} [outputEncoding] - The output encoding (default: `'hex'`)
|
|
148
|
+
*
|
|
149
|
+
* @returns {string | Buffer} The hash digest in the specified encoding
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';
|
|
154
|
+
*
|
|
155
|
+
* console.log(cryptoSha3512('test')); // b_NQJ8FJBY9dIjm1q7...
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
42
158
|
function cryptoSha3512(data, outputEncoding = "hex") {
|
|
43
159
|
return createHash("sha3-512").update(data).digest(outputEncoding);
|
|
44
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Computes the SHA-3 hash of the given data using the 512-bit digest and returns the raw buffer.
|
|
163
|
+
*
|
|
164
|
+
* @param {BinaryLike} data - The input data to hash
|
|
165
|
+
*
|
|
166
|
+
* @returns {Buffer} The raw hash digest as a Buffer
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';
|
|
171
|
+
*
|
|
172
|
+
* console.log(cryptoSha3512ToBuffer('test')); // <Buffer b_ NQ ...>
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
45
175
|
function cryptoSha3512ToBuffer(data) {
|
|
46
176
|
return createHash("sha3-512").update(data).digest();
|
|
47
177
|
}
|
package/dist/crypto-hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-hash.js","names":[],"sources":["../src/crypto-hash.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"crypto-hash.js","names":[],"sources":["../src/crypto-hash.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport type {\n BinaryLike,\n BinaryToTextEncoding,\n} 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 {BinaryToTextEncoding} [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')); // 33ed9a05a10b21f0...\n * ```\n */\nexport function cryptoMd5(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('md5').update(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(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 {BinaryToTextEncoding} [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')); // 0qW8FoqDcFmkpuqR9J3uT8YX...\n * ```\n */\nexport function cryptoSha3224(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-224').update(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 0q W8 Fo ...>\n * ```\n */\nexport function cryptoSha3224ToBuffer(data: BinaryLike) {\n return createHash('sha3-224').update(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 {BinaryToTextEncoding} [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: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-256').update(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(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 {BinaryToTextEncoding} [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')); // 1Q2wQAYaZ4o8vWX5bEB2n3Y...\n * ```\n */\nexport function cryptoSha3384(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-384').update(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 1Q 2w QZ ...>\n * ```\n */\nexport function cryptoSha3384ToBuffer(data: BinaryLike) {\n return createHash('sha3-384').update(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 {BinaryToTextEncoding} [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')); // b_NQJ8FJBY9dIjm1q7...\n * ```\n */\nexport function cryptoSha3512(data: BinaryLike, outputEncoding: BinaryToTextEncoding = 'hex') {\n return createHash('sha3-512').update(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 b_ NQ ...>\n * ```\n */\nexport function cryptoSha3512ToBuffer(data: BinaryLike) {\n return createHash('sha3-512').update(data).digest();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,SAAgB,UAAU,MAAkB,iBAAuC,OAAO;AACtF,QAAO,WAAW,MAAM,CAAC,OAAO,KAAK,CAAC,OAAO,eAAe;;;;;;;;;;;;;;;;AAiBhE,SAAgB,kBAAkB,MAAkB;AAChD,QAAO,WAAW,MAAM,CAAC,OAAO,KAAK,CAAC,QAAQ;;;;;;;;;;;;;;;;;AAkBlD,SAAgB,cAAc,MAAkB,iBAAuC,OAAO;AAC1F,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,OAAO,eAAe;;;;;;;;;;;;;;;;AAiBrE,SAAgB,sBAAsB,MAAkB;AACpD,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,QAAQ;;;;;;;;;;;;;;;;;AAkBvD,SAAgB,cAAc,MAAkB,iBAAuC,OAAO;AAC1F,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,OAAO,eAAe;;;;;;;;;;;;;;;;AAiBrE,SAAgB,sBAAsB,MAAkB;AACpD,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,QAAQ;;;;;;;;;;;;;;;;;AAkBvD,SAAgB,cAAc,MAAkB,iBAAuC,OAAO;AAC1F,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,OAAO,eAAe;;;;;;;;;;;;;;;;AAiBrE,SAAgB,sBAAsB,MAAkB;AACpD,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,QAAQ;;;;;;;;;;;;;;;;;AAkBvD,SAAgB,cAAc,MAAkB,iBAAuC,OAAO;AAC1F,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,OAAO,eAAe;;;;;;;;;;;;;;;;AAiBrE,SAAgB,sBAAsB,MAAkB;AACpD,QAAO,WAAW,WAAW,CAAC,OAAO,KAAK,CAAC,QAAQ"}
|
package/dist/datetime.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ type DateRangeType = 'lastMonth' | 'lastWeek' | 'thisMonth' | 'thisWeek' | 'toda
|
|
|
26
26
|
* // Format a date string
|
|
27
27
|
* console.log(formatDate('2024-07-10T00:00:00Z', 'yyyy-MM-dd')); // 2024-07-10
|
|
28
28
|
* ```
|
|
29
|
-
*
|
|
30
|
-
* @see https://date-fns.org/docs/format
|
|
31
29
|
*/
|
|
32
30
|
declare function formatDate(date: DateArg<Date> & {}, format?: string, options?: FormatOptions): string;
|
|
33
31
|
/**
|
package/dist/datetime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","names":[],"sources":["../src/datetime.ts"],"mappings":";;;KAkBY,aAAA;;AAAZ;;;;;
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","names":[],"sources":["../src/datetime.ts"],"mappings":";;;KAkBY,aAAA;;AAAZ;;;;;AA2BA;;;;;;;;;;;;;;;;AA+BA;;;iBA/BgB,UAAA,CAAW,IAAA,EAAM,OAAA,CAAQ,IAAA,QAAY,MAAA,WAAwC,OAAA,GAAU,aAAA;;;;;;;;;;;;;;;;;;;;;AAwGvG;;;;;;;iBAzEgB,oBAAA,CACZ,IAAA,EAAM,IAAA,EACN,IAAA,EAAM,aAAA,EACN,OAAA;EACI,wBAAA;EACA,YAAA,GAAe,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;iBAoEP,wBAAA,CAAyB,UAAA,YAAsB,IAAA"}
|
package/dist/datetime.js
CHANGED
|
@@ -24,8 +24,6 @@ import { endOfDay, endOfMonth, endOfWeek, format, startOfDay, startOfMonth, star
|
|
|
24
24
|
* // Format a date string
|
|
25
25
|
* console.log(formatDate('2024-07-10T00:00:00Z', 'yyyy-MM-dd')); // 2024-07-10
|
|
26
26
|
* ```
|
|
27
|
-
*
|
|
28
|
-
* @see https://date-fns.org/docs/format
|
|
29
27
|
*/
|
|
30
28
|
function formatDate(date, format$1 = "yyyy-MM-dd HH:mm:ss", options) {
|
|
31
29
|
return format(date, format$1, options);
|