@kikiutils/shared 15.0.3 → 15.1.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 (82) hide show
  1. package/README.md +137 -67
  2. package/dist/buffer.d.ts.map +1 -1
  3. package/dist/buffer.js.map +1 -1
  4. package/dist/classes/path.d.ts +8 -0
  5. package/dist/classes/path.d.ts.map +1 -1
  6. package/dist/classes/path.js +5 -0
  7. package/dist/classes/path.js.map +1 -1
  8. package/dist/classes/precision-number.d.ts +215 -11
  9. package/dist/classes/precision-number.d.ts.map +1 -1
  10. package/dist/classes/precision-number.js +268 -25
  11. package/dist/classes/precision-number.js.map +1 -1
  12. package/dist/classes/ssh-client.js.map +1 -1
  13. package/dist/clipboard.d.ts.map +1 -1
  14. package/dist/clipboard.js.map +1 -1
  15. package/dist/consola.d.ts.map +1 -1
  16. package/dist/consola.js.map +1 -1
  17. package/dist/crypto-hash.d.ts +7 -7
  18. package/dist/crypto-hash.d.ts.map +1 -1
  19. package/dist/crypto-hash.js +7 -7
  20. package/dist/crypto-hash.js.map +1 -1
  21. package/dist/datetime.d.ts.map +1 -1
  22. package/dist/datetime.js.map +1 -1
  23. package/dist/element-plus.d.ts.map +1 -1
  24. package/dist/element-plus.js.map +1 -1
  25. package/dist/enum.d.ts.map +1 -1
  26. package/dist/enum.js.map +1 -1
  27. package/dist/env.d.ts.map +1 -1
  28. package/dist/env.js.map +1 -1
  29. package/dist/event-awaiter.d.ts.map +1 -1
  30. package/dist/event-awaiter.js.map +1 -1
  31. package/dist/general.d.ts.map +1 -1
  32. package/dist/general.js.map +1 -1
  33. package/dist/hash.d.ts +3 -3
  34. package/dist/hash.d.ts.map +1 -1
  35. package/dist/hash.js +3 -3
  36. package/dist/hash.js.map +1 -1
  37. package/dist/math.d.ts.map +1 -1
  38. package/dist/math.js.map +1 -1
  39. package/dist/number.d.ts.map +1 -1
  40. package/dist/number.js.map +1 -1
  41. package/dist/object.d.ts.map +1 -1
  42. package/dist/object.js.map +1 -1
  43. package/dist/pino.d.ts.map +1 -1
  44. package/dist/pino.js.map +1 -1
  45. package/dist/random.d.ts.map +1 -1
  46. package/dist/random.js.map +1 -1
  47. package/dist/storages/lru/keyed-store.d.ts +3 -3
  48. package/dist/storages/lru/keyed-store.js +3 -3
  49. package/dist/storages/lru/keyed-store.js.map +1 -1
  50. package/dist/storages/redis/keyed-store.d.ts +1 -1
  51. package/dist/storages/redis/keyed-store.js +1 -1
  52. package/dist/storages/redis/keyed-store.js.map +1 -1
  53. package/dist/storages/redis/msgpack.d.ts.map +1 -1
  54. package/dist/storages/redis/msgpack.js.map +1 -1
  55. package/dist/storages/redis/types.d.ts.map +1 -1
  56. package/dist/string.d.ts +12 -6
  57. package/dist/string.d.ts.map +1 -1
  58. package/dist/string.js +9 -6
  59. package/dist/string.js.map +1 -1
  60. package/dist/time.d.ts.map +1 -1
  61. package/dist/time.js.map +1 -1
  62. package/dist/types/filtered-key-path.d.ts.map +1 -1
  63. package/dist/types/index.d.ts +30 -0
  64. package/dist/types/index.d.ts.map +1 -1
  65. package/dist/url.d.ts +27 -3
  66. package/dist/url.d.ts.map +1 -1
  67. package/dist/url.js +37 -4
  68. package/dist/url.js.map +1 -1
  69. package/dist/vue.d.ts.map +1 -1
  70. package/dist/vue.js.map +1 -1
  71. package/dist/web.d.ts.map +1 -1
  72. package/dist/web.js.map +1 -1
  73. package/package.json +12 -21
  74. package/src/classes/path.ts +9 -0
  75. package/src/classes/precision-number.ts +300 -25
  76. package/src/crypto-hash.ts +7 -7
  77. package/src/hash.ts +3 -3
  78. package/src/storages/lru/keyed-store.ts +3 -3
  79. package/src/storages/redis/keyed-store.ts +1 -1
  80. package/src/string.ts +12 -6
  81. package/src/types/index.ts +39 -0
  82. package/src/url.ts +39 -7
@@ -1 +1 @@
1
- {"version":3,"file":"precision-number.d.ts","names":[],"sources":["../../src/classes/precision-number.ts"],"mappings":";;;KAEY,oBAAA,GAAuB,OAAA,CAAQ,KAAA,G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IT,KAAA,CAAM,KAAA,EAAO,oBAAA;EAwIqB;;;;;;;EA5HlC,MAAA,CAAO,KAAA,EAAO,oBAAA;EA0JN;;;EAlJR,MAAA,CAAA;EAyJA;;;EAjJA,IAAA,CAAK,KAAA,EAAO,oBAAA;EAiJuB;AAAA;;;;;;EArInC,GAAA,CAAI,KAAA,EAAO,oBAAA;;;;EAQX,KAAA,CAAM,KAAA,EAAO,oBAAA;;;;EAQb,eAAA,CAAA,GAAe,eAAA;;;;EAOf,MAAA,CAAA,GAAM,eAAA;;;;;;;;;EAYN,SAAA,CAAU,GAAA,EAAK,oBAAA,EAAsB,GAAA,EAAK,oBAAA,GAAoB,eAAA;;;;EAO9D,WAAA,CAAY,KAAA,EAAO,oBAAA,GAAoB,eAAA;;;;EAWvC,OAAA,CAAA,GAAO,eAAA;;;;EAOP,MAAA,CAAA;;;;EAOA,OAAA,CAAQ,KAAA,EAAO,oBAAA,GAAoB,eAAA;;;;EAWnC,QAAA,CAAS,KAAA,EAAO,oBAAA,GAAoB,eAAA;;;;EAWpC,SAAA,CAAA,GAAS,eAAA;;;;EAOT,MAAA,CAAO,KAAA,EAAO,oBAAA,GAAoB,eAAA;;;;EAOlC,KAAA,CAAM,KAAA,EAAO,oBAAA,GAAoB,eAAA;;;;;;EASjC,QAAA,CAAA;;;;EAOA,QAAA,CAAA;;;;EAOA,OAAA,CAAQ,aAAA,WAA6C,QAAA,GAAU,OAAA,CAAQ,QAAA;;;;EAOvE,OAAA,CAAQ,KAAA,EAAO,oBAAA,GAAoB,eAAA;AAAA"}
@@ -1,33 +1,51 @@
1
1
  import { Decimal } from "decimal.js";
2
2
  //#region src/classes/precision-number.ts
3
3
  /**
4
- * Class representing a precision number with configurable decimal places and rounding.
4
+ * Chainable fixed-decimal wrapper around `decimal.js`.
5
5
  *
6
- * This class leverages the Decimal.js library to ensure accurate arithmetic operations
7
- * with floating point numbers. It provides methods for various arithmetic operations
8
- * (addition, subtraction, multiplication, division) as well as comparison and utility
9
- * methods to check the state of the number (e.g., if it is finite, an integer, zero, etc.).
6
+ * `PrecisionNumber` stores values as `Decimal`, rounds every mutating operation to
7
+ * the configured decimal places, and exposes both mutable and immutable arithmetic
8
+ * methods. Mutable methods (`plus`, `minus`, `times`, `dividedBy`, `modulo`,
9
+ * `pow`, `clamp`, `ceil`, `floor`, `negate`, `absoluteValue`) update the current
10
+ * instance and return `this`; immutable methods prefixed with `to` return a new
11
+ * `PrecisionNumber` with the same precision settings.
10
12
  *
11
- * The class also includes custom symbol methods to support Node.js inspection and primitive
12
- * type conversion.
13
+ * @example
14
+ * ```typescript
15
+ * import { PrecisionNumber } from '@kikiutils/shared/classes/precision-number';
13
16
  *
14
- * The class supports in-place modification methods that alter the current instance's value,
15
- * such as `plus`, `minus`, `times`, `dividedBy`, and others. Additionally, methods prefixed
16
- * with `to` (e.g., `toPlus`, `toMinus`) return a new instance of `PrecisionNumber` with the
17
- * modified value, leaving the original instance unchanged.
17
+ * const value = new PrecisionNumber('1.239', 2).plus('2.111');
18
+ * value.toString(); // '3.35'
19
+ * value.toMinus('1').toString(); // '2.35' (original value remains '3.35')
20
+ * ```
18
21
  */
19
22
  var PrecisionNumber = class PrecisionNumber {
20
23
  #decimalPlaces;
21
24
  #rounding;
22
25
  #decimal;
26
+ /**
27
+ * Creates a fixed-decimal number.
28
+ *
29
+ * @param {PrecisionNumberValue} [value] - Initial value (default: `'0'`)
30
+ * @param {number} [decimalPlaces] - Decimal places retained after operations (default: `2`)
31
+ * @param {Decimal.Rounding} [rounding] - Decimal.js rounding mode (default: `Decimal.ROUND_DOWN`)
32
+ */
23
33
  constructor(value = "0", decimalPlaces = 2, rounding = Decimal.ROUND_DOWN) {
24
34
  this.#decimalPlaces = decimalPlaces;
25
35
  this.#rounding = rounding;
26
36
  this.#decimal = this.#decimalToFixedDecimal(new Decimal(value.toString().trim()));
27
37
  }
38
+ /**
39
+ * Returns the formatted value when inspected by Node.js utilities.
40
+ */
28
41
  [Symbol.for("nodejs.util.inspect.custom")]() {
29
42
  return this.value;
30
43
  }
44
+ /**
45
+ * Converts to a number for numeric coercion and to the fixed string otherwise.
46
+ *
47
+ * @param {string} hint - JavaScript primitive-conversion hint
48
+ */
31
49
  [Symbol.toPrimitive](hint) {
32
50
  if (hint === "number") return this.#decimal.toNumber();
33
51
  return this.value;
@@ -35,95 +53,320 @@ var PrecisionNumber = class PrecisionNumber {
35
53
  #decimalToFixedDecimal(decimal) {
36
54
  return decimal.toDecimalPlaces(this.#decimalPlaces, this.#rounding);
37
55
  }
56
+ #valueToString(value) {
57
+ return value.toString().trim();
58
+ }
59
+ /**
60
+ * Decimal places retained by mutating operations and default formatting.
61
+ */
62
+ get decimalPlaces() {
63
+ return this.#decimalPlaces;
64
+ }
65
+ /**
66
+ * Decimal.js rounding mode used by mutating operations and default formatting.
67
+ */
68
+ get rounding() {
69
+ return this.#rounding;
70
+ }
71
+ /**
72
+ * Fixed-decimal string using the instance precision and rounding mode.
73
+ */
38
74
  get value() {
39
75
  return this.#decimal.toFixed(this.#decimalPlaces, this.#rounding);
40
76
  }
77
+ /**
78
+ * Formats a value with decimal.js without creating a reusable instance.
79
+ *
80
+ * @param {PrecisionNumberValue} value - Value to format
81
+ * @param {number} [decimalPlaces] - Decimal places to output (default: `2`)
82
+ * @param {Decimal.Rounding} [rounding] - Decimal.js rounding mode (default: `Decimal.ROUND_DOWN`)
83
+ *
84
+ * @returns {string} Fixed-decimal string
85
+ */
41
86
  static toFixed(value, decimalPlaces = 2, rounding = Decimal.ROUND_DOWN) {
42
87
  return new Decimal(value.toString().trim()).toFixed(decimalPlaces, rounding);
43
88
  }
89
+ /**
90
+ * Replaces the current value with its absolute value.
91
+ *
92
+ * @returns {this} The current instance for chaining
93
+ */
44
94
  absoluteValue() {
45
95
  this.#decimal = this.#decimalToFixedDecimal(this.#decimal.absoluteValue());
46
96
  return this;
47
97
  }
98
+ /**
99
+ * Rounds the current value up to the nearest integer in place.
100
+ *
101
+ * The stored value still uses this instance's configured decimal places for output.
102
+ *
103
+ * @returns {this} The current instance for chaining
104
+ */
105
+ ceil() {
106
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.ceil());
107
+ return this;
108
+ }
109
+ /**
110
+ * Restricts the current value to the inclusive range `[min, max]` in place.
111
+ *
112
+ * @param {PrecisionNumberValue} min - Lower bound
113
+ * @param {PrecisionNumberValue} max - Upper bound
114
+ *
115
+ * @returns {this} The current instance for chaining
116
+ *
117
+ * @throws {Error} If `min` is greater than `max`
118
+ */
119
+ clamp(min, max) {
120
+ const minDecimal = new Decimal(this.#valueToString(min));
121
+ const maxDecimal = new Decimal(this.#valueToString(max));
122
+ if (minDecimal.gt(maxDecimal)) throw new Error("Invalid clamp range: min cannot be greater than max");
123
+ this.#decimal = this.#decimalToFixedDecimal(Decimal.min(Decimal.max(this.#decimal, minDecimal), maxDecimal));
124
+ return this;
125
+ }
126
+ /**
127
+ * Returns a new instance with the same value, decimal places, and rounding mode.
128
+ */
129
+ clone() {
130
+ return new PrecisionNumber(this.#decimal, this.#decimalPlaces, this.#rounding);
131
+ }
132
+ /**
133
+ * Divides the current value by another value in place.
134
+ *
135
+ * @param {PrecisionNumberValue} value - Divisor
136
+ *
137
+ * @returns {this} The current instance for chaining
138
+ */
48
139
  dividedBy(value) {
49
- this.#decimal = this.#decimalToFixedDecimal(this.#decimal.dividedBy(value.toString().trim()));
140
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.dividedBy(this.#valueToString(value)));
50
141
  return this;
51
142
  }
143
+ /**
144
+ * Checks whether the current value equals another value.
145
+ *
146
+ * @param {PrecisionNumberValue} value - Value to compare
147
+ *
148
+ * @returns {boolean} `true` when both numeric values are equal
149
+ */
52
150
  equals(value) {
53
- return this.#decimal.equals(value.toString().trim());
151
+ return this.#decimal.equals(this.#valueToString(value));
152
+ }
153
+ /**
154
+ * Rounds the current value down to the nearest integer in place.
155
+ *
156
+ * The stored value still uses this instance's configured decimal places for output.
157
+ *
158
+ * @returns {this} The current instance for chaining
159
+ */
160
+ floor() {
161
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.floor());
162
+ return this;
54
163
  }
164
+ /**
165
+ * Checks whether the current value is greater than another value.
166
+ */
55
167
  gt(value) {
56
- return this.#decimal.gt(value.toString().trim());
168
+ return this.#decimal.gt(this.#valueToString(value));
57
169
  }
170
+ /**
171
+ * Checks whether the current value is greater than or equal to another value.
172
+ */
58
173
  gte(value) {
59
- return this.#decimal.gte(value.toString().trim());
174
+ return this.#decimal.gte(this.#valueToString(value));
60
175
  }
176
+ /**
177
+ * Checks whether the current value is finite.
178
+ */
61
179
  isFinite() {
62
180
  return this.#decimal.isFinite();
63
181
  }
182
+ /**
183
+ * Checks whether the current value is an integer.
184
+ */
64
185
  isInteger() {
65
186
  return this.#decimal.isInteger();
66
187
  }
188
+ /**
189
+ * Checks whether the current value is `NaN`.
190
+ */
67
191
  isNaN() {
68
192
  return this.#decimal.isNaN();
69
193
  }
194
+ /**
195
+ * Checks whether the current value is negative.
196
+ */
70
197
  isNegative() {
71
198
  return this.#decimal.isNegative();
72
199
  }
200
+ /**
201
+ * Checks whether the current value is positive.
202
+ */
73
203
  isPositive() {
74
204
  return this.#decimal.isPositive();
75
205
  }
206
+ /**
207
+ * Checks whether the current value is zero.
208
+ */
76
209
  isZero() {
77
210
  return this.#decimal.isZero();
78
211
  }
212
+ /**
213
+ * Checks whether the current value is less than another value.
214
+ */
79
215
  lt(value) {
80
- return this.#decimal.lt(value.toString().trim());
216
+ return this.#decimal.lt(this.#valueToString(value));
81
217
  }
218
+ /**
219
+ * Checks whether the current value is less than or equal to another value.
220
+ */
82
221
  lte(value) {
83
- return this.#decimal.lte(value.toString().trim());
222
+ return this.#decimal.lte(this.#valueToString(value));
84
223
  }
224
+ /**
225
+ * Subtracts another value from the current value in place.
226
+ */
85
227
  minus(value) {
86
- this.#decimal = this.#decimalToFixedDecimal(this.#decimal.minus(value.toString().trim()));
228
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.minus(this.#valueToString(value)));
87
229
  return this;
88
230
  }
231
+ /**
232
+ * Replaces the current value with the remainder after division by another value.
233
+ *
234
+ * @param {PrecisionNumberValue} value - Divisor used to compute the remainder
235
+ *
236
+ * @returns {this} The current instance for chaining
237
+ */
238
+ modulo(value) {
239
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.modulo(this.#valueToString(value)));
240
+ return this;
241
+ }
242
+ /**
243
+ * Negates the current value in place.
244
+ */
89
245
  negate() {
90
246
  this.#decimal = this.#decimalToFixedDecimal(this.#decimal.negated());
91
247
  return this;
92
248
  }
249
+ /**
250
+ * Adds another value to the current value in place.
251
+ */
93
252
  plus(value) {
94
- this.#decimal = this.#decimalToFixedDecimal(this.#decimal.plus(value.toString().trim()));
253
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.plus(this.#valueToString(value)));
254
+ return this;
255
+ }
256
+ /**
257
+ * Raises the current value to an exponent in place.
258
+ *
259
+ * @param {PrecisionNumberValue} value - Exponent
260
+ *
261
+ * @returns {this} The current instance for chaining
262
+ */
263
+ pow(value) {
264
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.pow(this.#valueToString(value)));
95
265
  return this;
96
266
  }
267
+ /**
268
+ * Multiplies the current value by another value in place.
269
+ */
97
270
  times(value) {
98
- this.#decimal = this.#decimalToFixedDecimal(this.#decimal.times(value.toString().trim()));
271
+ this.#decimal = this.#decimalToFixedDecimal(this.#decimal.times(this.#valueToString(value)));
99
272
  return this;
100
273
  }
274
+ /**
275
+ * Returns a new instance with the absolute value.
276
+ */
101
277
  toAbsoluteValue() {
102
278
  return new PrecisionNumber(this.#decimal.absoluteValue(), this.#decimalPlaces, this.#rounding);
103
279
  }
280
+ /**
281
+ * Returns a new instance rounded up to the nearest integer.
282
+ */
283
+ toCeil() {
284
+ return new PrecisionNumber(this.#decimal.ceil(), this.#decimalPlaces, this.#rounding);
285
+ }
286
+ /**
287
+ * Returns a new instance restricted to the inclusive range `[min, max]`.
288
+ *
289
+ * @param {PrecisionNumberValue} min - Lower bound
290
+ * @param {PrecisionNumberValue} max - Upper bound
291
+ *
292
+ * @throws {Error} If `min` is greater than `max`
293
+ */
294
+ toClamped(min, max) {
295
+ return this.clone().clamp(min, max);
296
+ }
297
+ /**
298
+ * Returns a new instance divided by another value.
299
+ */
104
300
  toDividedBy(value) {
105
- return new PrecisionNumber(this.#decimal.dividedBy(value.toString().trim()), this.#decimalPlaces, this.#rounding);
301
+ return new PrecisionNumber(this.#decimal.dividedBy(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
106
302
  }
303
+ /**
304
+ * Returns a new instance rounded down to the nearest integer.
305
+ */
306
+ toFloor() {
307
+ return new PrecisionNumber(this.#decimal.floor(), this.#decimalPlaces, this.#rounding);
308
+ }
309
+ /**
310
+ * Serializes to the fixed-decimal string.
311
+ */
107
312
  toJSON() {
108
313
  return this.value;
109
314
  }
315
+ /**
316
+ * Returns a new instance with another value subtracted.
317
+ */
110
318
  toMinus(value) {
111
- return new PrecisionNumber(this.#decimal.minus(value.toString().trim()), this.#decimalPlaces, this.#rounding);
319
+ return new PrecisionNumber(this.#decimal.minus(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
320
+ }
321
+ /**
322
+ * Returns a new instance with the remainder after division by another value.
323
+ */
324
+ toModulo(value) {
325
+ return new PrecisionNumber(this.#decimal.modulo(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
112
326
  }
327
+ /**
328
+ * Returns a new instance with the value negated.
329
+ */
113
330
  toNegated() {
114
331
  return new PrecisionNumber(this.#decimal.negated(), this.#decimalPlaces, this.#rounding);
115
332
  }
333
+ /**
334
+ * Returns a new instance with another value added.
335
+ */
116
336
  toPlus(value) {
117
- return new PrecisionNumber(this.#decimal.plus(value.toString().trim()), this.#decimalPlaces, this.#rounding);
118
- }
337
+ return new PrecisionNumber(this.#decimal.plus(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
338
+ }
339
+ /**
340
+ * Returns a new instance raised to an exponent.
341
+ */
342
+ toPow(value) {
343
+ return new PrecisionNumber(this.#decimal.pow(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
344
+ }
345
+ /**
346
+ * Converts the current value to a JavaScript number.
347
+ *
348
+ * Use `toString`/`value` when preserving decimal precision is more important than native-number ergonomics.
349
+ */
350
+ toNumber() {
351
+ return this.#decimal.toNumber();
352
+ }
353
+ /**
354
+ * Converts the current value to its fixed-decimal string.
355
+ */
119
356
  toString() {
120
357
  return this.value;
121
358
  }
359
+ /**
360
+ * Formats the current value with custom precision and rounding for this call only.
361
+ */
122
362
  toFixed(decimalPlaces = this.#decimalPlaces, rounding = this.#rounding) {
123
363
  return this.#decimal.toFixed(decimalPlaces, rounding);
124
364
  }
365
+ /**
366
+ * Returns a new instance multiplied by another value.
367
+ */
125
368
  toTimes(value) {
126
- return new PrecisionNumber(this.#decimal.times(value.toString().trim()), this.#decimalPlaces, this.#rounding);
369
+ return new PrecisionNumber(this.#decimal.times(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);
127
370
  }
128
371
  };
129
372
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"precision-number.js","names":["#decimalPlaces","#rounding","#decimal","#decimalToFixedDecimal"],"sources":["../../src/classes/precision-number.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\nexport type PrecisionNumberValue = Decimal.Value | PrecisionNumber | { toString: () => string };\n\n/**\n * Class representing a precision number with configurable decimal places and rounding.\n *\n * This class leverages the Decimal.js library to ensure accurate arithmetic operations\n * with floating point numbers. It provides methods for various arithmetic operations\n * (addition, subtraction, multiplication, division) as well as comparison and utility\n * methods to check the state of the number (e.g., if it is finite, an integer, zero, etc.).\n *\n * The class also includes custom symbol methods to support Node.js inspection and primitive\n * type conversion.\n *\n * The class supports in-place modification methods that alter the current instance's value,\n * such as `plus`, `minus`, `times`, `dividedBy`, and others. Additionally, methods prefixed\n * with `to` (e.g., `toPlus`, `toMinus`) return a new instance of `PrecisionNumber` with the\n * modified value, leaving the original instance unchanged.\n */\nexport class PrecisionNumber {\n // Private properties\n readonly #decimalPlaces: number;\n readonly #rounding: Decimal.Rounding;\n #decimal: Decimal;\n\n constructor(\n value: PrecisionNumberValue = '0',\n decimalPlaces: number = 2,\n rounding: Decimal.Rounding = Decimal.ROUND_DOWN,\n ) {\n this.#decimalPlaces = decimalPlaces;\n this.#rounding = rounding;\n this.#decimal = this.#decimalToFixedDecimal(new Decimal(value.toString().trim()));\n }\n\n // Symbols\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.value;\n }\n\n [Symbol.toPrimitive](hint: string) {\n if (hint === 'number') return this.#decimal.toNumber();\n return this.value;\n }\n\n // Private methods\n #decimalToFixedDecimal(decimal: Decimal) {\n return decimal.toDecimalPlaces(this.#decimalPlaces, this.#rounding);\n }\n\n // Public getters\n get value() {\n return this.#decimal.toFixed(this.#decimalPlaces, this.#rounding);\n }\n\n // Static methods\n static toFixed(\n value: PrecisionNumberValue,\n decimalPlaces: number = 2,\n rounding: Decimal.Rounding = Decimal.ROUND_DOWN,\n ) {\n return new Decimal(value.toString().trim()).toFixed(decimalPlaces, rounding);\n }\n\n // Public methods\n absoluteValue() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.absoluteValue());\n return this;\n }\n\n dividedBy(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.dividedBy(value.toString().trim()));\n return this;\n }\n\n equals(value: PrecisionNumberValue) {\n return this.#decimal.equals(value.toString().trim());\n }\n\n gt(value: PrecisionNumberValue) {\n return this.#decimal.gt(value.toString().trim());\n }\n\n gte(value: PrecisionNumberValue) {\n return this.#decimal.gte(value.toString().trim());\n }\n\n isFinite() {\n return this.#decimal.isFinite();\n }\n\n isInteger() {\n return this.#decimal.isInteger();\n }\n\n isNaN() {\n return this.#decimal.isNaN();\n }\n\n isNegative() {\n return this.#decimal.isNegative();\n }\n\n isPositive() {\n return this.#decimal.isPositive();\n }\n\n isZero() {\n return this.#decimal.isZero();\n }\n\n lt(value: PrecisionNumberValue) {\n return this.#decimal.lt(value.toString().trim());\n }\n\n lte(value: PrecisionNumberValue) {\n return this.#decimal.lte(value.toString().trim());\n }\n\n minus(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.minus(value.toString().trim()));\n return this;\n }\n\n negate() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.negated());\n return this;\n }\n\n plus(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.plus(value.toString().trim()));\n return this;\n }\n\n times(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.times(value.toString().trim()));\n return this;\n }\n\n toAbsoluteValue() {\n return new PrecisionNumber(this.#decimal.absoluteValue(), this.#decimalPlaces, this.#rounding);\n }\n\n toDividedBy(value: PrecisionNumberValue) {\n return new PrecisionNumber(\n this.#decimal.dividedBy(value.toString().trim()),\n this.#decimalPlaces,\n this.#rounding,\n );\n }\n\n toJSON() {\n return this.value;\n }\n\n toMinus(value: PrecisionNumberValue) {\n return new PrecisionNumber(this.#decimal.minus(value.toString().trim()), this.#decimalPlaces, this.#rounding);\n }\n\n toNegated() {\n return new PrecisionNumber(this.#decimal.negated(), this.#decimalPlaces, this.#rounding);\n }\n\n toPlus(value: PrecisionNumberValue) {\n return new PrecisionNumber(this.#decimal.plus(value.toString().trim()), this.#decimalPlaces, this.#rounding);\n }\n\n toString() {\n return this.value;\n }\n\n toFixed(decimalPlaces: number = this.#decimalPlaces, rounding: Decimal.Rounding = this.#rounding) {\n return this.#decimal.toFixed(decimalPlaces, rounding);\n }\n\n toTimes(value: PrecisionNumberValue) {\n return new PrecisionNumber(this.#decimal.times(value.toString().trim()), this.#decimalPlaces, this.#rounding);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,IAAa,kBAAb,MAAa,gBAAgB;CAEzB;CACA;CACA;CAEA,YACI,QAA8B,KAC9B,gBAAwB,GACxB,WAA6B,QAAQ,YACvC;AACE,QA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A,eAAqB,MAAA,SAAe;;CAGhH,WAAW;AACP,SAAO,KAAK;;CAGhB,QAAQ,gBAAwB,MAAA,eAAqB,WAA6B,MAAA,UAAgB;AAC9F,SAAO,MAAA,QAAc,QAAQ,eAAe,SAAS;;CAGzD,QAAQ,OAA6B;AACjC,SAAO,IAAI,gBAAgB,MAAA,QAAc,MAAM,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,MAAA,eAAqB,MAAA,SAAe"}
1
+ {"version":3,"file":"precision-number.js","names":["#decimalPlaces","#rounding","#decimal","#decimalToFixedDecimal","#valueToString"],"sources":["../../src/classes/precision-number.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\n\n/**\n * Values accepted by `PrecisionNumber` constructors and arithmetic methods.\n */\nexport type PrecisionNumberValue = Decimal.Value | PrecisionNumber | { toString: () => string };\n\n/**\n * Chainable fixed-decimal wrapper around `decimal.js`.\n *\n * `PrecisionNumber` stores values as `Decimal`, rounds every mutating operation to\n * the configured decimal places, and exposes both mutable and immutable arithmetic\n * methods. Mutable methods (`plus`, `minus`, `times`, `dividedBy`, `modulo`,\n * `pow`, `clamp`, `ceil`, `floor`, `negate`, `absoluteValue`) update the current\n * instance and return `this`; immutable methods prefixed with `to` return a new\n * `PrecisionNumber` with the same precision settings.\n *\n * @example\n * ```typescript\n * import { PrecisionNumber } from '@kikiutils/shared/classes/precision-number';\n *\n * const value = new PrecisionNumber('1.239', 2).plus('2.111');\n * value.toString(); // '3.35'\n * value.toMinus('1').toString(); // '2.35' (original value remains '3.35')\n * ```\n */\nexport class PrecisionNumber {\n // Private properties\n readonly #decimalPlaces: number;\n readonly #rounding: Decimal.Rounding;\n #decimal: Decimal;\n\n /**\n * Creates a fixed-decimal number.\n *\n * @param {PrecisionNumberValue} [value] - Initial value (default: `'0'`)\n * @param {number} [decimalPlaces] - Decimal places retained after operations (default: `2`)\n * @param {Decimal.Rounding} [rounding] - Decimal.js rounding mode (default: `Decimal.ROUND_DOWN`)\n */\n constructor(\n value: PrecisionNumberValue = '0',\n decimalPlaces: number = 2,\n rounding: Decimal.Rounding = Decimal.ROUND_DOWN,\n ) {\n this.#decimalPlaces = decimalPlaces;\n this.#rounding = rounding;\n this.#decimal = this.#decimalToFixedDecimal(new Decimal(value.toString().trim()));\n }\n\n // Symbols\n\n /**\n * Returns the formatted value when inspected by Node.js utilities.\n */\n [Symbol.for('nodejs.util.inspect.custom')]() {\n return this.value;\n }\n\n /**\n * Converts to a number for numeric coercion and to the fixed string otherwise.\n *\n * @param {string} hint - JavaScript primitive-conversion hint\n */\n [Symbol.toPrimitive](hint: string) {\n if (hint === 'number') return this.#decimal.toNumber();\n return this.value;\n }\n\n // Private methods\n #decimalToFixedDecimal(decimal: Decimal) {\n return decimal.toDecimalPlaces(this.#decimalPlaces, this.#rounding);\n }\n\n #valueToString(value: PrecisionNumberValue) {\n return value.toString().trim();\n }\n\n // Public getters\n\n /**\n * Decimal places retained by mutating operations and default formatting.\n */\n get decimalPlaces() {\n return this.#decimalPlaces;\n }\n\n /**\n * Decimal.js rounding mode used by mutating operations and default formatting.\n */\n get rounding() {\n return this.#rounding;\n }\n\n /**\n * Fixed-decimal string using the instance precision and rounding mode.\n */\n get value() {\n return this.#decimal.toFixed(this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Formats a value with decimal.js without creating a reusable instance.\n *\n * @param {PrecisionNumberValue} value - Value to format\n * @param {number} [decimalPlaces] - Decimal places to output (default: `2`)\n * @param {Decimal.Rounding} [rounding] - Decimal.js rounding mode (default: `Decimal.ROUND_DOWN`)\n *\n * @returns {string} Fixed-decimal string\n */\n static toFixed(\n value: PrecisionNumberValue,\n decimalPlaces: number = 2,\n rounding: Decimal.Rounding = Decimal.ROUND_DOWN,\n ) {\n return new Decimal(value.toString().trim()).toFixed(decimalPlaces, rounding);\n }\n\n // Public methods\n\n /**\n * Replaces the current value with its absolute value.\n *\n * @returns {this} The current instance for chaining\n */\n absoluteValue() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.absoluteValue());\n return this;\n }\n\n /**\n * Rounds the current value up to the nearest integer in place.\n *\n * The stored value still uses this instance's configured decimal places for output.\n *\n * @returns {this} The current instance for chaining\n */\n ceil() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.ceil());\n return this;\n }\n\n /**\n * Restricts the current value to the inclusive range `[min, max]` in place.\n *\n * @param {PrecisionNumberValue} min - Lower bound\n * @param {PrecisionNumberValue} max - Upper bound\n *\n * @returns {this} The current instance for chaining\n *\n * @throws {Error} If `min` is greater than `max`\n */\n clamp(min: PrecisionNumberValue, max: PrecisionNumberValue) {\n const minDecimal = new Decimal(this.#valueToString(min));\n const maxDecimal = new Decimal(this.#valueToString(max));\n if (minDecimal.gt(maxDecimal)) throw new Error('Invalid clamp range: min cannot be greater than max');\n this.#decimal = this.#decimalToFixedDecimal(Decimal.min(Decimal.max(this.#decimal, minDecimal), maxDecimal));\n return this;\n }\n\n /**\n * Returns a new instance with the same value, decimal places, and rounding mode.\n */\n clone() {\n return new PrecisionNumber(this.#decimal, this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Divides the current value by another value in place.\n *\n * @param {PrecisionNumberValue} value - Divisor\n *\n * @returns {this} The current instance for chaining\n */\n dividedBy(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.dividedBy(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Checks whether the current value equals another value.\n *\n * @param {PrecisionNumberValue} value - Value to compare\n *\n * @returns {boolean} `true` when both numeric values are equal\n */\n equals(value: PrecisionNumberValue) {\n return this.#decimal.equals(this.#valueToString(value));\n }\n\n /**\n * Rounds the current value down to the nearest integer in place.\n *\n * The stored value still uses this instance's configured decimal places for output.\n *\n * @returns {this} The current instance for chaining\n */\n floor() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.floor());\n return this;\n }\n\n /**\n * Checks whether the current value is greater than another value.\n */\n gt(value: PrecisionNumberValue) {\n return this.#decimal.gt(this.#valueToString(value));\n }\n\n /**\n * Checks whether the current value is greater than or equal to another value.\n */\n gte(value: PrecisionNumberValue) {\n return this.#decimal.gte(this.#valueToString(value));\n }\n\n /**\n * Checks whether the current value is finite.\n */\n isFinite() {\n return this.#decimal.isFinite();\n }\n\n /**\n * Checks whether the current value is an integer.\n */\n isInteger() {\n return this.#decimal.isInteger();\n }\n\n /**\n * Checks whether the current value is `NaN`.\n */\n isNaN() {\n return this.#decimal.isNaN();\n }\n\n /**\n * Checks whether the current value is negative.\n */\n isNegative() {\n return this.#decimal.isNegative();\n }\n\n /**\n * Checks whether the current value is positive.\n */\n isPositive() {\n return this.#decimal.isPositive();\n }\n\n /**\n * Checks whether the current value is zero.\n */\n isZero() {\n return this.#decimal.isZero();\n }\n\n /**\n * Checks whether the current value is less than another value.\n */\n lt(value: PrecisionNumberValue) {\n return this.#decimal.lt(this.#valueToString(value));\n }\n\n /**\n * Checks whether the current value is less than or equal to another value.\n */\n lte(value: PrecisionNumberValue) {\n return this.#decimal.lte(this.#valueToString(value));\n }\n\n /**\n * Subtracts another value from the current value in place.\n */\n minus(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.minus(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Replaces the current value with the remainder after division by another value.\n *\n * @param {PrecisionNumberValue} value - Divisor used to compute the remainder\n *\n * @returns {this} The current instance for chaining\n */\n modulo(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.modulo(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Negates the current value in place.\n */\n negate() {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.negated());\n return this;\n }\n\n /**\n * Adds another value to the current value in place.\n */\n plus(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.plus(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Raises the current value to an exponent in place.\n *\n * @param {PrecisionNumberValue} value - Exponent\n *\n * @returns {this} The current instance for chaining\n */\n pow(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.pow(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Multiplies the current value by another value in place.\n */\n times(value: PrecisionNumberValue) {\n this.#decimal = this.#decimalToFixedDecimal(this.#decimal.times(this.#valueToString(value)));\n return this;\n }\n\n /**\n * Returns a new instance with the absolute value.\n */\n toAbsoluteValue() {\n return new PrecisionNumber(this.#decimal.absoluteValue(), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Returns a new instance rounded up to the nearest integer.\n */\n toCeil() {\n return new PrecisionNumber(this.#decimal.ceil(), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Returns a new instance restricted to the inclusive range `[min, max]`.\n *\n * @param {PrecisionNumberValue} min - Lower bound\n * @param {PrecisionNumberValue} max - Upper bound\n *\n * @throws {Error} If `min` is greater than `max`\n */\n toClamped(min: PrecisionNumberValue, max: PrecisionNumberValue) {\n return this.clone().clamp(min, max);\n }\n\n /**\n * Returns a new instance divided by another value.\n */\n toDividedBy(value: PrecisionNumberValue) {\n return new PrecisionNumber(\n this.#decimal.dividedBy(this.#valueToString(value)),\n this.#decimalPlaces,\n this.#rounding,\n );\n }\n\n /**\n * Returns a new instance rounded down to the nearest integer.\n */\n toFloor() {\n return new PrecisionNumber(this.#decimal.floor(), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Serializes to the fixed-decimal string.\n */\n toJSON() {\n return this.value;\n }\n\n /**\n * Returns a new instance with another value subtracted.\n */\n toMinus(value: PrecisionNumberValue) {\n return new PrecisionNumber(\n this.#decimal.minus(this.#valueToString(value)),\n this.#decimalPlaces,\n this.#rounding,\n );\n }\n\n /**\n * Returns a new instance with the remainder after division by another value.\n */\n toModulo(value: PrecisionNumberValue) {\n return new PrecisionNumber(\n this.#decimal.modulo(this.#valueToString(value)),\n this.#decimalPlaces,\n this.#rounding,\n );\n }\n\n /**\n * Returns a new instance with the value negated.\n */\n toNegated() {\n return new PrecisionNumber(this.#decimal.negated(), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Returns a new instance with another value added.\n */\n toPlus(value: PrecisionNumberValue) {\n return new PrecisionNumber(this.#decimal.plus(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Returns a new instance raised to an exponent.\n */\n toPow(value: PrecisionNumberValue) {\n return new PrecisionNumber(this.#decimal.pow(this.#valueToString(value)), this.#decimalPlaces, this.#rounding);\n }\n\n /**\n * Converts the current value to a JavaScript number.\n *\n * Use `toString`/`value` when preserving decimal precision is more important than native-number ergonomics.\n */\n toNumber() {\n return this.#decimal.toNumber();\n }\n\n /**\n * Converts the current value to its fixed-decimal string.\n */\n toString() {\n return this.value;\n }\n\n /**\n * Formats the current value with custom precision and rounding for this call only.\n */\n toFixed(decimalPlaces: number = this.#decimalPlaces, rounding: Decimal.Rounding = this.#rounding) {\n return this.#decimal.toFixed(decimalPlaces, rounding);\n }\n\n /**\n * Returns a new instance multiplied by another value.\n */\n toTimes(value: PrecisionNumberValue) {\n return new PrecisionNumber(\n this.#decimal.times(this.#valueToString(value)),\n this.#decimalPlaces,\n this.#rounding,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,kBAAb,MAAa,gBAAgB;CAEzB;CACA;CACA;;;;;;;;CASA,YACI,QAA8B,KAC9B,gBAAwB,GACxB,WAA6B,QAAQ,YACvC;EACE,KAAKA,iBAAiB;EACtB,KAAKC,YAAY;EACjB,KAAKC,WAAW,KAAKC,uBAAuB,IAAI,QAAQ,MAAM,SAAS,EAAE,KAAK,CAAC,CAAC;CACpF;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAK;EACzC,OAAO,KAAK;CAChB;;;;;;CAOA,CAAC,OAAO,aAAa,MAAc;EAC/B,IAAI,SAAS,UAAU,OAAO,KAAKD,SAAS,SAAS;EACrD,OAAO,KAAK;CAChB;CAGA,uBAAuB,SAAkB;EACrC,OAAO,QAAQ,gBAAgB,KAAKF,gBAAgB,KA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6B;EAChC,OAAO,IAAI,gBAAgB,KAAKC,SAAS,KAAK,KAAKE,eAAe,KAAK,CAAC,GAAG,KAAKJ,gBAAgB,KAAKC,SAAS;CAClH;;;;CAKA,MAAM,OAA6B;EAC/B,OAAO,IAAI,gBAAgB,KAAKC,SAAS,IAAI,KAAKE,eAAe,KAAK,CAAC,GAAG,KAAKJ,gBAAgB,KAAKC,SAAS;CACjH;;;;;;CAOA,WAAW;EACP,OAAO,KAAKC,SAAS,SAAS;CAClC;;;;CAKA,WAAW;EACP,OAAO,KAAK;CAChB;;;;CAKA,QAAQ,gBAAwB,KAAKF,gBAAgB,WAA6B,KAAKC,WAAW;EAC9F,OAAO,KAAKC,SAAS,QAAQ,eAAe,QAAQ;CACxD;;;;CAKA,QAAQ,OAA6B;EACjC,OAAO,IAAI,gBACP,KAAKA,SAAS,MAAM,KAAKE,eAAe,KAAK,CAAC,GAC9C,KAAKJ,gBACL,KAAKC,SACT;CACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"ssh-client.js","names":["#connectConfig","#logger","#nodeSsh"],"sources":["../../src/classes/ssh-client.ts"],"sourcesContent":["import { createConsola } from 'consola';\nimport type { ConsolaInstance } from 'consola';\nimport { NodeSSH } from 'node-ssh';\nimport type {\n Config,\n SSHExecCommandOptions,\n SSHGetPutDirectoryOptions,\n SSHPutFilesOptions,\n} from 'node-ssh';\nimport type {\n SFTPWrapper,\n TransferOptions,\n} from 'ssh2';\n\nimport type { Nullable } from '../types';\n\nimport type { PathLike } from './path';\n\nconst loggerLevelStringToConsolaLogLevelMap = {\n debug: 4,\n error: 0,\n fatal: 0,\n info: 3,\n normal: 2,\n silent: -999,\n trace: 5,\n verbose: 999,\n warn: 1,\n} as const;\n\nexport class SshClient {\n readonly #connectConfig: Config;\n readonly #logger: ConsolaInstance;\n\n #nodeSsh: NodeSSH;\n\n constructor(host: string, username: string, password: string, port: number = 22, connectConfig?: Config) {\n this.#connectConfig = {\n ...connectConfig,\n host,\n password,\n port,\n username,\n };\n\n this.#logger = createConsola();\n this.#nodeSsh = new NodeSSH();\n if (process.env.NODE_ENV === 'production') this.setLoggerLevel('error');\n }\n\n get nodeSsh() {\n return this.#nodeSsh;\n }\n\n async connect() {\n try {\n this.#nodeSsh = await this.#nodeSsh.connect(this.#connectConfig);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n disconnect() {\n try {\n this.#nodeSsh.dispose();\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n execCommand(command: string, options?: SSHExecCommandOptions) {\n return this.#nodeSsh.execCommand(command, options).catch(() => {});\n }\n\n execCommandWithIo(command: string, options?: SSHExecCommandOptions) {\n return this.execCommand(\n command,\n {\n ...options,\n onStderr: (data) => process.stderr.write(data.toString()),\n onStdout: (data) => process.stdout.write(data.toString()),\n },\n );\n }\n\n getDir = this.getDirectory;\n\n async getDirectory(localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions) {\n try {\n return await this.#nodeSsh.getDirectory(localDirectory.toString(), remoteDirectory.toString(), options);\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async getFile(\n localFile: PathLike,\n remoteFile: PathLike,\n givenSftp?: Nullable<SFTPWrapper>,\n transferOptions?: Nullable<TransferOptions>,\n ) {\n try {\n await this.#nodeSsh.getFile(localFile.toString(), remoteFile.toString(), givenSftp, transferOptions);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n isConnected() {\n return this.#nodeSsh.isConnected();\n }\n\n async mkdir(path: PathLike) {\n try {\n await this.#nodeSsh.mkdir(path.toString());\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n putDir = this.putDirectory;\n\n async putDirectory(localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions) {\n try {\n return await this.#nodeSsh.putDirectory(localDirectory.toString(), remoteDirectory.toString(), options);\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async putFile(\n localFile: PathLike,\n remoteFile: PathLike,\n givenSftp?: Nullable<SFTPWrapper>,\n transferOptions?: Nullable<TransferOptions>,\n ) {\n try {\n await this.#nodeSsh.putFile(localFile.toString(), remoteFile.toString(), givenSftp, transferOptions);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async putFiles(files: { local: PathLike; remote: PathLike }[], options?: SSHPutFilesOptions) {\n try {\n const convertedFiles = files.map(({ local, remote }) => ({\n local: local.toString(),\n remote: remote.toString(),\n }));\n\n await this.#nodeSsh.putFiles(convertedFiles, options);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n setLoggerLevel(level: keyof typeof loggerLevelStringToConsolaLogLevelMap) {\n this.#logger.level = loggerLevelStringToConsolaLogLevelMap[level];\n }\n}\n"],"mappings":";;;AAkBA,MAAM,wCAAwC;CAC1C,OAAO;CACP,OAAO;CACP,OAAO;CACP,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,SAAS;CACT,MAAM;CACT;AAED,IAAa,YAAb,MAAuB;CACnB;CACA;CAEA;CAEA,YAAY,MAAc,UAAkB,UAAkB,OAAe,IAAI,eAAwB;AACrG,QAAA,gBAAsB;GAClB,GAAG;GACH;GACA;GACA;GACA;GACH;AAED,QAAA,SAAe,eAAe;AAC9B,QAAA,UAAgB,IAAI,SAAS;AAC7B,MAAI,QAAQ,IAAI,aAAa,aAAc,MAAK,eAAe,QAAQ;;CAG3E,IAAI,UAAU;AACV,SAAO,MAAA;;CAGX,MAAM,UAAU;AACZ,MAAI;AACA,SAAA,UAAgB,MAAM,MAAA,QAAc,QAAQ,MAAA,cAAoB;AAChE,UAAO;WACF,OAAO;AACZ,SAAA,OAAa,MAAM,MAAM;AACzB,UAAO;;;CAIf,aAAa;AACT,MAAI;AACA,SAAA,QAAc,SAAS;AACvB,UAAO;WACF,OAAO;AACZ,SAAA,OAAa,MAAM,MAAM;AACzB,UAAO;;;CAIf,YAAY,SAA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Z,SAAA,OAAa,MAAM,MAAM;AACzB,UAAO;;;CAIf,MAAM,SAAS,OAAgD,SAA8B;AACzF,MAAI;GACA,MAAM,iBAAiB,MAAM,KAAK,EAAE,OAAO,cAAc;IACrD,OAAO,MAAM,UAAU;IACvB,QAAQ,OAAO,UAAU;IAC5B,EAAE;AAEH,SAAM,MAAA,QAAc,SAAS,gBAAgB,QAAQ;AACrD,UAAO;WACF,OAAO;AACZ,SAAA,OAAa,MAAM,MAAM;AACzB,UAAO;;;CAIf,eAAe,OAA2D;AACtE,QAAA,OAAa,QAAQ,sCAAsC"}
1
+ {"version":3,"file":"ssh-client.js","names":["#connectConfig","#logger","#nodeSsh"],"sources":["../../src/classes/ssh-client.ts"],"sourcesContent":["import { createConsola } from 'consola';\nimport type { ConsolaInstance } from 'consola';\nimport { NodeSSH } from 'node-ssh';\nimport type {\n Config,\n SSHExecCommandOptions,\n SSHGetPutDirectoryOptions,\n SSHPutFilesOptions,\n} from 'node-ssh';\nimport type {\n SFTPWrapper,\n TransferOptions,\n} from 'ssh2';\n\nimport type { Nullable } from '../types';\n\nimport type { PathLike } from './path';\n\nconst loggerLevelStringToConsolaLogLevelMap = {\n debug: 4,\n error: 0,\n fatal: 0,\n info: 3,\n normal: 2,\n silent: -999,\n trace: 5,\n verbose: 999,\n warn: 1,\n} as const;\n\nexport class SshClient {\n readonly #connectConfig: Config;\n readonly #logger: ConsolaInstance;\n\n #nodeSsh: NodeSSH;\n\n constructor(host: string, username: string, password: string, port: number = 22, connectConfig?: Config) {\n this.#connectConfig = {\n ...connectConfig,\n host,\n password,\n port,\n username,\n };\n\n this.#logger = createConsola();\n this.#nodeSsh = new NodeSSH();\n if (process.env.NODE_ENV === 'production') this.setLoggerLevel('error');\n }\n\n get nodeSsh() {\n return this.#nodeSsh;\n }\n\n async connect() {\n try {\n this.#nodeSsh = await this.#nodeSsh.connect(this.#connectConfig);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n disconnect() {\n try {\n this.#nodeSsh.dispose();\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n execCommand(command: string, options?: SSHExecCommandOptions) {\n return this.#nodeSsh.execCommand(command, options).catch(() => {});\n }\n\n execCommandWithIo(command: string, options?: SSHExecCommandOptions) {\n return this.execCommand(\n command,\n {\n ...options,\n onStderr: (data) => process.stderr.write(data.toString()),\n onStdout: (data) => process.stdout.write(data.toString()),\n },\n );\n }\n\n getDir = this.getDirectory;\n\n async getDirectory(localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions) {\n try {\n return await this.#nodeSsh.getDirectory(localDirectory.toString(), remoteDirectory.toString(), options);\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async getFile(\n localFile: PathLike,\n remoteFile: PathLike,\n givenSftp?: Nullable<SFTPWrapper>,\n transferOptions?: Nullable<TransferOptions>,\n ) {\n try {\n await this.#nodeSsh.getFile(localFile.toString(), remoteFile.toString(), givenSftp, transferOptions);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n isConnected() {\n return this.#nodeSsh.isConnected();\n }\n\n async mkdir(path: PathLike) {\n try {\n await this.#nodeSsh.mkdir(path.toString());\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n putDir = this.putDirectory;\n\n async putDirectory(localDirectory: PathLike, remoteDirectory: PathLike, options?: SSHGetPutDirectoryOptions) {\n try {\n return await this.#nodeSsh.putDirectory(localDirectory.toString(), remoteDirectory.toString(), options);\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async putFile(\n localFile: PathLike,\n remoteFile: PathLike,\n givenSftp?: Nullable<SFTPWrapper>,\n transferOptions?: Nullable<TransferOptions>,\n ) {\n try {\n await this.#nodeSsh.putFile(localFile.toString(), remoteFile.toString(), givenSftp, transferOptions);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n async putFiles(files: { local: PathLike; remote: PathLike }[], options?: SSHPutFilesOptions) {\n try {\n const convertedFiles = files.map(({ local, remote }) => ({\n local: local.toString(),\n remote: remote.toString(),\n }));\n\n await this.#nodeSsh.putFiles(convertedFiles, options);\n return true;\n } catch (error) {\n this.#logger.error(error);\n return false;\n }\n }\n\n setLoggerLevel(level: keyof typeof loggerLevelStringToConsolaLogLevelMap) {\n this.#logger.level = loggerLevelStringToConsolaLogLevelMap[level];\n }\n}\n"],"mappings":";;;AAkBA,MAAM,wCAAwC;CAC1C,OAAO;CACP,OAAO;CACP,OAAO;CACP,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,SAAS;CACT,MAAM;AACV;AAEA,IAAa,YAAb,MAAuB;CACnB;CACA;CAEA;CAEA,YAAY,MAAc,UAAkB,UAAkB,OAAe,IAAI,eAAwB;EACrG,KAAKA,iBAAiB;GAClB,GAAG;GACH;GACA;GACA;GACA;EACJ;EAEA,KAAKC,UAAU,cAAc;EAC7B,KAAKC,WAAW,IAAI,QAAQ;EAC5B,IAAI,QAAQ,IAAI,aAAa,cAAc,KAAK,eAAe,OAAO;CAC1E;CAEA,IAAI,UAAU;EACV,OAAO,KAAKA;CAChB;CAEA,MAAM,UAAU;EACZ,IAAI;GACA,KAAKA,WAAW,MAAM,KAAKA,SAAS,QAAQ,KAAKF,cAAc;GAC/D,OAAO;EACX,SAAS,OAAO;GACZ,KAAKC,QAAQ,MAAM,KAAK;GACxB,OAAO;EACX;CACJ;CAEA,aAAa;EACT,IAAI;GACA,KAAKC,SAAS,QAAQ;GACtB,OAAO;EACX,SAAS,OAAO;GACZ,KAAKD,QAAQ,MAAM,KAAK;GACxB,OAAO;EACX;CACJ;CAEA,YAAY,SAAiB,SAAiC;EAC1D,OAAO,KAAKC,SAAS,YAAY,SAAS,OAAO,EAAE,YAAY,CAAC,CAAC;CACrE;CAEA,kBAAkB,SAAiB,SAAiC;EAChE,OAAO,KAAK,YACR,SACA;GACI,GAAG;GACH,WAAW,SAAS,QAAQ,OAAO,MAAM,KAA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A,MAAM,iBAAiB,MAAM,KAAK,EAAE,OAAO,cAAc;IACrD,OAAO,MAAM,SAAS;IACtB,QAAQ,OAAO,SAAS;GAC5B,EAAE;GAEF,MAAM,KAAKC,SAAS,SAAS,gBAAgB,OAAO;GACpD,OAAO;EACX,SAAS,OAAO;GACZ,KAAKD,QAAQ,MAAM,KAAK;GACxB,OAAO;EACX;CACJ;CAEA,eAAe,OAA2D;EACtE,KAAKA,QAAQ,QAAQ,sCAAsC;CAC/D;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.d.ts","names":[],"sources":["../src/clipboard.ts"],"mappings":";KAAK,UAAA;EACC,KAAA;EAAgB,EAAA;AAAA;EAChB,EAAA;AAAA;;;;;AA8BN;;;;;;;;;;;;;;;;;AA8CA;;;;;;;iBA9CsB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,OAAA,GAAU,oBAAA,GAAuB,OAAA,CAAQ,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CzE,mBAAA,CAAoB,IAAA,WAAe,OAAA,CAAQ,UAAA"}
1
+ {"version":3,"file":"clipboard.d.ts","names":[],"sources":["../src/clipboard.ts"],"mappings":";KAAK,UAAA;EACC,KAAA;EAAgB,EAAA;AAAA;EAChB,EAAA;AAAA;;;;AAAE;AA8BR;;;;;;;;;;;;;;;;AAAyG;AA8CzG;;;;;;;iBA9CsB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,OAAA,GAAU,oBAAA,GAAuB,OAAA,CAAQ,UAAA;AA8CpB;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAArD,mBAAA,CAAoB,IAAA,WAAe,OAAO,CAAC,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,eAAsB,oBAAoB,MAAY,SAAqD;AACvG,KAAI,CAAC,UAAU,WAAW,MACtB,QAAO;EACH,uBAAO,IAAI,MAAM,mDAAmD;EACpE,IAAI;EACP;AAGL,KAAI;EACA,MAAM,OAAO,IAAI,cAAc,GAAG,KAAK,OAAO,MAAM,EAAE,QAAQ;AAC9D,QAAM,UAAU,UAAU,MAAM,CAAC,KAAK,CAAC;AACvC,SAAO,EAAE,IAAI,MAAM;UACd,OAAO;AACZ,SAAO;GACH;GACA,IAAI;GACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BT,eAAsB,oBAAoB,MAAmC;AACzE,KAAI;AACA,QAAM,UAAU,UAAU,UAAU,KAAK;AACzC,SAAO,EAAE,IAAI,MAAM;UACd,OAAO;AACZ,SAAO;GACH;GACA,IAAI;GACP"}
1
+ {"version":3,"file":"clipboard.js","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,eAAsB,oBAAoB,MAAY,SAAqD;CACvG,IAAI,CAAC,UAAU,WAAW,OACtB,OAAO;EACH,uBAAO,IAAI,MAAM,kDAAkD;EACnE,IAAI;CACR;CAGJ,IAAI;EACA,MAAM,OAAO,IAAI,cAAc,GAAG,KAAK,OAAO,KAAK,GAAG,OAAO;EAC7D,MAAM,UAAU,UAAU,MAAM,CAAC,IAAI,CAAC;EACtC,OAAO,EAAE,IAAI,KAAK;CACtB,SAAS,OAAO;EACZ,OAAO;GACH;GACA,IAAI;EACR;CACJ;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,oBAAoB,MAAmC;CACzE,IAAI;EACA,MAAM,UAAU,UAAU,UAAU,IAAI;EACxC,OAAO,EAAE,IAAI,KAAK;CACtB,SAAS,OAAO;EACZ,OAAO;GACH;GACA,IAAI;EACR;CACJ;AACJ"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"consola.d.ts","names":[],"sources":["../src/consola.ts"],"mappings":";;;;;;AAuBA;;;;AAA4C;AAC5C;;;;AAAmC;;;;;;;;;cADtB,aAAA,EAA+B,SAAA,CAAlB,eAAkB;AAAA,cAC/B,MAAA,EAAsB,SAAA,CAAhB,eAAgB"}
@@ -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,eAAe;AAC5C,MAAa,SAAS;AACtB,IAAI,QAAQ,IAAI,yBAAyB,KAAA,EAAW,eAAc,QAAQ,CAAC,QAAQ,IAAI;IAClF,eAAc,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 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"}
@@ -13,7 +13,7 @@ import { BinaryLike, BinaryToTextEncoding } from "node:crypto";
13
13
  * ```typescript
14
14
  * import { cryptoMd5 } from '@kikiutils/shared/crypto-hash';
15
15
  *
16
- * console.log(cryptoMd5('test')); // 33ed9a05a10b21f0...
16
+ * console.log(cryptoMd5('test')); // 098f6bcd4621d373cade4e832627b4f6
17
17
  * ```
18
18
  */
19
19
  declare function cryptoMd5(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
@@ -44,7 +44,7 @@ declare function cryptoMd5ToBuffer(data: BinaryLike): NonSharedBuffer;
44
44
  * ```typescript
45
45
  * import { cryptoSha3224 } from '@kikiutils/shared/crypto-hash';
46
46
  *
47
- * console.log(cryptoSha3224('test')); // 0qW8FoqDcFmkpuqR9J3uT8YX...
47
+ * console.log(cryptoSha3224('test')); // 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
48
48
  * ```
49
49
  */
50
50
  declare function cryptoSha3224(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
@@ -59,7 +59,7 @@ declare function cryptoSha3224(data: BinaryLike, outputEncoding?: BinaryToTextEn
59
59
  * ```typescript
60
60
  * import { cryptoSha3224ToBuffer } from '@kikiutils/shared/crypto-hash';
61
61
  *
62
- * console.log(cryptoSha3224ToBuffer('test')); // <Buffer 0q W8 Fo ...>
62
+ * console.log(cryptoSha3224ToBuffer('test')); // <Buffer 37 97 bf 0a ...>
63
63
  * ```
64
64
  */
65
65
  declare function cryptoSha3224ToBuffer(data: BinaryLike): NonSharedBuffer;
@@ -106,7 +106,7 @@ declare function cryptoSha3256ToBuffer(data: BinaryLike): NonSharedBuffer;
106
106
  * ```typescript
107
107
  * import { cryptoSha3384 } from '@kikiutils/shared/crypto-hash';
108
108
  *
109
- * console.log(cryptoSha3384('test')); // 1Q2wQAYaZ4o8vWX5bEB2n3Y...
109
+ * console.log(cryptoSha3384('test')); // e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7f...
110
110
  * ```
111
111
  */
112
112
  declare function cryptoSha3384(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
@@ -121,7 +121,7 @@ declare function cryptoSha3384(data: BinaryLike, outputEncoding?: BinaryToTextEn
121
121
  * ```typescript
122
122
  * import { cryptoSha3384ToBuffer } from '@kikiutils/shared/crypto-hash';
123
123
  *
124
- * console.log(cryptoSha3384ToBuffer('test')); // <Buffer 1Q 2w QZ ...>
124
+ * console.log(cryptoSha3384ToBuffer('test')); // <Buffer e5 16 da bb ...>
125
125
  * ```
126
126
  */
127
127
  declare function cryptoSha3384ToBuffer(data: BinaryLike): NonSharedBuffer;
@@ -137,7 +137,7 @@ declare function cryptoSha3384ToBuffer(data: BinaryLike): NonSharedBuffer;
137
137
  * ```typescript
138
138
  * import { cryptoSha3512 } from '@kikiutils/shared/crypto-hash';
139
139
  *
140
- * console.log(cryptoSha3512('test')); // b_NQJ8FJBY9dIjm1q7...
140
+ * console.log(cryptoSha3512('test')); // 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7...
141
141
  * ```
142
142
  */
143
143
  declare function cryptoSha3512(data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
@@ -152,7 +152,7 @@ declare function cryptoSha3512(data: BinaryLike, outputEncoding?: BinaryToTextEn
152
152
  * ```typescript
153
153
  * import { cryptoSha3512ToBuffer } from '@kikiutils/shared/crypto-hash';
154
154
  *
155
- * console.log(cryptoSha3512ToBuffer('test')); // <Buffer b_ NQ ...>
155
+ * console.log(cryptoSha3512ToBuffer('test')); // <Buffer 9e ce 08 6e ...>
156
156
  * ```
157
157
  */
158
158
  declare function cryptoSha3512ToBuffer(data: BinaryLike): NonSharedBuffer;
@@ -1 +1 @@
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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