@rsdoctor/utils 1.5.10 → 1.5.12
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/compiled/filesize/index.d.ts +96 -56
- package/compiled/filesize/index.js +735 -225
- package/compiled/filesize/license +28 -28
- package/compiled/filesize/package.json +1 -1
- package/dist/build.cjs +3 -3
- package/dist/common.cjs +17 -17
- package/dist/error.cjs +2 -2
- package/dist/logger.cjs +3 -3
- package/dist/ruleUtils.cjs +9 -9
- package/package.json +6 -6
|
@@ -1,58 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Options interface for configuring filesize behavior
|
|
3
|
+
*/
|
|
4
|
+
interface FilesizeOptions {
|
|
5
|
+
/** If true, calculates bits instead of bytes */
|
|
6
|
+
bits?: boolean;
|
|
7
|
+
/** If true, pads decimal places to match round parameter */
|
|
8
|
+
pad?: boolean;
|
|
9
|
+
/** Number base (2 for binary, 10 for decimal, -1 for auto) */
|
|
10
|
+
base?: number;
|
|
11
|
+
/** Number of decimal places to round to */
|
|
12
|
+
round?: number;
|
|
13
|
+
/** Locale for number formatting, true for system locale */
|
|
14
|
+
locale?: string | boolean;
|
|
15
|
+
/** Additional options for locale formatting */
|
|
16
|
+
localeOptions?: Intl.NumberFormatOptions;
|
|
17
|
+
/** Custom decimal separator */
|
|
18
|
+
separator?: string;
|
|
19
|
+
/** String to separate value and unit */
|
|
20
|
+
spacer?: string;
|
|
21
|
+
/** Custom unit symbols */
|
|
22
|
+
symbols?: Record<string, string>;
|
|
23
|
+
/** Unit standard to use (SI, IEC, JEDEC) */
|
|
24
|
+
standard?: "si" | "iec" | "jedec" | "";
|
|
25
|
+
/** Output format: "string", "array", "object", or "exponent" */
|
|
26
|
+
output?: "string" | "array" | "object" | "exponent";
|
|
27
|
+
/** If true, uses full unit names instead of abbreviations */
|
|
28
|
+
fullform?: boolean;
|
|
29
|
+
/** Custom full unit names */
|
|
30
|
+
fullforms?: string[];
|
|
31
|
+
/** Force specific exponent (-1 for auto) */
|
|
32
|
+
exponent?: number;
|
|
33
|
+
/** Math rounding method to use */
|
|
34
|
+
roundingMethod?: "round" | "floor" | "ceil";
|
|
35
|
+
/** Number of significant digits (0 for auto) */
|
|
36
|
+
precision?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Object format return type when output is "object"
|
|
41
|
+
*/
|
|
42
|
+
interface FilesizeObject {
|
|
43
|
+
/** The numeric value */
|
|
44
|
+
value: number | string;
|
|
45
|
+
/** The unit symbol */
|
|
46
|
+
symbol: string;
|
|
47
|
+
/** The exponent used in calculation */
|
|
48
|
+
exponent: number;
|
|
49
|
+
/** The original unit before symbol customization */
|
|
50
|
+
unit: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Array format return type when output is "array"
|
|
55
|
+
*/
|
|
56
|
+
type FilesizeArray = [number | string, string];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Return type based on output option
|
|
60
|
+
*/
|
|
61
|
+
type FilesizeReturn<T extends FilesizeOptions = {}> =
|
|
62
|
+
T['output'] extends "object" ? FilesizeObject :
|
|
63
|
+
T['output'] extends "array" ? FilesizeArray :
|
|
64
|
+
T['output'] extends "exponent" ? number :
|
|
65
|
+
string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Converts a file size in bytes to a human-readable string with appropriate units
|
|
69
|
+
* @param arg - The file size in bytes to convert
|
|
70
|
+
* @param options - Configuration options for formatting
|
|
71
|
+
* @returns Formatted file size based on output option
|
|
72
|
+
* @throws {TypeError} When arg is not a valid number or roundingMethod is invalid
|
|
73
|
+
* @example
|
|
74
|
+
* filesize(1024) // "1.02 kB"
|
|
75
|
+
* filesize(1024, {bits: true}) // "8.19 kbit"
|
|
76
|
+
* filesize(1024, {output: "object"}) // {value: 1.02, symbol: "kB", exponent: 1, unit: "kB"}
|
|
77
|
+
*/
|
|
78
|
+
declare function filesize<T extends FilesizeOptions = {}>(
|
|
79
|
+
arg: number | string | bigint,
|
|
80
|
+
options?: T
|
|
81
|
+
): FilesizeReturn<T>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Creates a partially applied version of filesize with preset options
|
|
85
|
+
* @param options - Default options to apply to the returned function
|
|
86
|
+
* @returns A function that takes a file size and returns formatted output
|
|
87
|
+
* @example
|
|
88
|
+
* const formatBytes = partial({round: 1, standard: "iec"});
|
|
89
|
+
* formatBytes(1024) // "1 KiB"
|
|
90
|
+
* formatBytes(2048) // "2 KiB"
|
|
91
|
+
* formatBytes(1536) // "1.5 KiB"
|
|
92
|
+
*/
|
|
93
|
+
declare function partial<T extends FilesizeOptions = {}>(
|
|
94
|
+
options?: T
|
|
95
|
+
): (arg: number | string | bigint) => FilesizeReturn<T>;
|
|
57
96
|
|
|
58
97
|
export { filesize, partial };
|
|
98
|
+
export type { FilesizeArray, FilesizeObject, FilesizeOptions, FilesizeReturn };
|