tiny-essentials 1.8.2 → 1.8.3

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.
@@ -2203,8 +2203,8 @@ async function asyncReplace(str, regex, asyncFn) {
2203
2203
  * This implementation ensures a uniform distribution of permutations.
2204
2204
  * Original algorithm source: StackOverflow (link above).
2205
2205
  *
2206
- * @param {string[]} items - The array to shuffle.
2207
- * @returns {string[]} The same array instance, now shuffled in place.
2206
+ * @param {any[]} items - The array to shuffle.
2207
+ * @returns {any[]} The same array instance, now shuffled in place.
2208
2208
  */
2209
2209
  function shuffleArray(items) {
2210
2210
  let currentIndex = items.length,
@@ -2805,13 +2805,19 @@ function getAge(timeData = 0, now = null) {
2805
2805
  return null;
2806
2806
  }
2807
2807
 
2808
+ /**
2809
+ * @typedef {Object} FormattedByteResult
2810
+ * @property {string|null} unit - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
2811
+ * @property {number|null} value - The numerical value in the chosen unit, or null if input is invalid.
2812
+ */
2813
+
2808
2814
  /**
2809
2815
  * Converts a byte value into a human-readable format with unit and value separated.
2810
2816
  *
2811
2817
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
2812
2818
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
2813
2819
  * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
2814
- * @returns {{ unit: string|null, value: number|null }} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
2820
+ * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
2815
2821
  *
2816
2822
  * @example
2817
2823
  * formatBytes(123456789);
@@ -2349,8 +2349,8 @@ class TinyLevelUp {
2349
2349
  * This implementation ensures a uniform distribution of permutations.
2350
2350
  * Original algorithm source: StackOverflow (link above).
2351
2351
  *
2352
- * @param {string[]} items - The array to shuffle.
2353
- * @returns {string[]} The same array instance, now shuffled in place.
2352
+ * @param {any[]} items - The array to shuffle.
2353
+ * @returns {any[]} The same array instance, now shuffled in place.
2354
2354
  */
2355
2355
  function shuffleArray(items) {
2356
2356
  let currentIndex = items.length,
@@ -2951,13 +2951,19 @@ function getAge(timeData = 0, now = null) {
2951
2951
  return null;
2952
2952
  }
2953
2953
 
2954
+ /**
2955
+ * @typedef {Object} FormattedByteResult
2956
+ * @property {string|null} unit - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
2957
+ * @property {number|null} value - The numerical value in the chosen unit, or null if input is invalid.
2958
+ */
2959
+
2954
2960
  /**
2955
2961
  * Converts a byte value into a human-readable format with unit and value separated.
2956
2962
  *
2957
2963
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
2958
2964
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
2959
2965
  * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
2960
- * @returns {{ unit: string|null, value: number|null }} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
2966
+ * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
2961
2967
  *
2962
2968
  * @example
2963
2969
  * formatBytes(123456789);
@@ -8,8 +8,8 @@
8
8
  * This implementation ensures a uniform distribution of permutations.
9
9
  * Original algorithm source: StackOverflow (link above).
10
10
  *
11
- * @param {string[]} items - The array to shuffle.
12
- * @returns {string[]} The same array instance, now shuffled in place.
11
+ * @param {any[]} items - The array to shuffle.
12
+ * @returns {any[]} The same array instance, now shuffled in place.
13
13
  */
14
14
  function shuffleArray(items) {
15
15
  let currentIndex = items.length,
@@ -4,8 +4,8 @@
4
4
  * This implementation ensures a uniform distribution of permutations.
5
5
  * Original algorithm source: StackOverflow (link above).
6
6
  *
7
- * @param {string[]} items - The array to shuffle.
8
- * @returns {string[]} The same array instance, now shuffled in place.
7
+ * @param {any[]} items - The array to shuffle.
8
+ * @returns {any[]} The same array instance, now shuffled in place.
9
9
  */
10
- export function shuffleArray(items: string[]): string[];
10
+ export function shuffleArray(items: any[]): any[];
11
11
  //# sourceMappingURL=array.d.mts.map
@@ -5,8 +5,8 @@
5
5
  * This implementation ensures a uniform distribution of permutations.
6
6
  * Original algorithm source: StackOverflow (link above).
7
7
  *
8
- * @param {string[]} items - The array to shuffle.
9
- * @returns {string[]} The same array instance, now shuffled in place.
8
+ * @param {any[]} items - The array to shuffle.
9
+ * @returns {any[]} The same array instance, now shuffled in place.
10
10
  */
11
11
  export function shuffleArray(items) {
12
12
  let currentIndex = items.length, randomIndex;
@@ -83,13 +83,19 @@ function getAge(timeData = 0, now = null) {
83
83
  return null;
84
84
  }
85
85
 
86
+ /**
87
+ * @typedef {Object} FormattedByteResult
88
+ * @property {string|null} unit - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
89
+ * @property {number|null} value - The numerical value in the chosen unit, or null if input is invalid.
90
+ */
91
+
86
92
  /**
87
93
  * Converts a byte value into a human-readable format with unit and value separated.
88
94
  *
89
95
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
90
96
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
91
97
  * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
92
- * @returns {{ unit: string|null, value: number|null }} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
98
+ * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
93
99
  *
94
100
  * @example
95
101
  * formatBytes(123456789);
@@ -52,13 +52,18 @@ export function getSimplePerc(price: number, percentage: number): number;
52
52
  * @returns {number|null} The age in years, or null if `timeData` is not provided or invalid.
53
53
  */
54
54
  export function getAge(timeData?: number | string | Date, now?: Date | null): number | null;
55
+ /**
56
+ * @typedef {Object} FormattedByteResult
57
+ * @property {string|null} unit - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
58
+ * @property {number|null} value - The numerical value in the chosen unit, or null if input is invalid.
59
+ */
55
60
  /**
56
61
  * Converts a byte value into a human-readable format with unit and value separated.
57
62
  *
58
63
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
59
64
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
60
65
  * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
61
- * @returns {{ unit: string|null, value: number|null }} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
66
+ * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
62
67
  *
63
68
  * @example
64
69
  * formatBytes(123456789);
@@ -68,8 +73,15 @@ export function getAge(timeData?: number | string | Date, now?: Date | null): nu
68
73
  * formatBytes(1073741824, 2, 'MB');
69
74
  * // → { unit: 'MB', value: 1024 }
70
75
  */
71
- export function formatBytes(bytes: number, decimals?: number | null, maxUnit?: string | null): {
76
+ export function formatBytes(bytes: number, decimals?: number | null, maxUnit?: string | null): FormattedByteResult;
77
+ export type FormattedByteResult = {
78
+ /**
79
+ * - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
80
+ */
72
81
  unit: string | null;
82
+ /**
83
+ * - The numerical value in the chosen unit, or null if input is invalid.
84
+ */
73
85
  value: number | null;
74
86
  };
75
87
  //# sourceMappingURL=simpleMath.d.mts.map
@@ -73,13 +73,18 @@ export function getAge(timeData = 0, now = null) {
73
73
  }
74
74
  return null;
75
75
  }
76
+ /**
77
+ * @typedef {Object} FormattedByteResult
78
+ * @property {string|null} unit - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
79
+ * @property {number|null} value - The numerical value in the chosen unit, or null if input is invalid.
80
+ */
76
81
  /**
77
82
  * Converts a byte value into a human-readable format with unit and value separated.
78
83
  *
79
84
  * @param {number} bytes - The number of bytes to format. Must be a non-negative number.
80
85
  * @param {number|null} [decimals=null] - The number of decimal places to include in the result. Defaults to null. If negative, it will be treated as 0. If null, no rounding is applied.
81
86
  * @param {string|null} [maxUnit=null] - Optional unit limit. If provided, restricts conversion to this unit at most (e.g., 'MB' prevents conversion to 'GB' or higher). Must be one of: 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'.
82
- * @returns {{ unit: string|null, value: number|null }} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
87
+ * @returns {FormattedByteResult} An object with the converted value and its corresponding unit. Returns nulls if input is invalid.
83
88
  *
84
89
  * @example
85
90
  * formatBytes(123456789);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",