|
1 |
| -export interface FileSizeOptions { |
| 1 | +interface FileSizeOptionsBase { |
| 2 | + base?: number; |
2 | 3 | bits?: boolean;
|
| 4 | + exponent?: number; |
| 5 | + fullform?: boolean; |
| 6 | + fullforms?: string[]; |
| 7 | + locale?: string | boolean; |
| 8 | + localeOptions?: Intl.DateTimeFormatOptions; |
3 | 9 | pad?: boolean;
|
4 |
| - base?: number; |
| 10 | + precision?: number; |
5 | 11 | round?: number;
|
6 |
| - locale?: string; |
7 |
| - localeOptions?: {}; |
| 12 | + roundingMethod?: 'round' | 'floor' | 'ceil'; |
8 | 13 | separator?: string;
|
9 | 14 | spacer?: string;
|
10 |
| - symbols?: {}; |
11 | 15 | standard?: 'iec' | 'jedec';
|
12 |
| - output?: 'array' | 'exponent' | 'object' | 'string'; |
13 |
| - fullform?: boolean; |
14 |
| - fullforms?: any[]; |
15 |
| - exponent?: number; |
16 |
| - roundingMethod?: 'round' | 'floor' | 'ceil'; |
17 |
| - precision?: number; |
| 16 | + symbols?: { |
| 17 | + iec: { |
| 18 | + bits: string[], |
| 19 | + bytes: string[] |
| 20 | + }, |
| 21 | + jedec: { |
| 22 | + bits: string[], |
| 23 | + bytes: string[] |
| 24 | + } |
| 25 | + }; |
| 26 | +} |
| 27 | + |
| 28 | +interface FileSizeOptionsArray extends FileSizeOptionsBase { |
| 29 | + output: 'array' |
| 30 | +} |
| 31 | + |
| 32 | +interface FileSizeOptionsExponent extends FileSizeOptionsBase { |
| 33 | + output: 'exponent' |
18 | 34 | }
|
19 | 35 |
|
20 |
| -export function filesize(arg: any, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision }?: FileSizeOptions): string | number | any[] | { |
21 |
| - value: any; |
22 |
| - symbol: any; |
23 |
| - exponent: number; |
24 |
| - unit: string; |
25 |
| -}; |
26 |
| - |
27 |
| -export function partial({ bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision }?: FileSizeOptions): (arg: any) => string | number | any[] | { |
28 |
| - value: any; |
29 |
| - symbol: any; |
30 |
| - exponent: number; |
31 |
| - unit: string; |
32 |
| -}; |
| 36 | +interface FileSizeOptionsObject extends FileSizeOptionsBase { |
| 37 | + output: 'object' |
| 38 | +} |
| 39 | + |
| 40 | +interface FileSizeOptionsString extends FileSizeOptionsBase { |
| 41 | + output: 'string' |
| 42 | +} |
| 43 | + |
| 44 | +interface FileSizeReturnObject { |
| 45 | + value: string, |
| 46 | + symbol: string, |
| 47 | + exponent: number, |
| 48 | + unit: string, |
| 49 | +} |
| 50 | + |
| 51 | +type FileSizeReturnArray = [ number, string ] |
| 52 | + |
| 53 | +export function filesize(byteCount: number, options: FileSizeOptionsString | FileSizeOptionsBase): string |
| 54 | +export function filesize(byteCount: number, options: FileSizeOptionsArray): FileSizeReturnArray |
| 55 | +export function filesize(byteCount: number, options: FileSizeOptionsExponent): number |
| 56 | +export function filesize(byteCount: number, options: FileSizeOptionsObject): FileSizeReturnObject |
| 57 | +export function filesize(byteCount: number): string |
| 58 | + |
| 59 | +export function partial(options: FileSizeOptionsString | FileSizeOptionsBase): (byteCount: number) => string |
| 60 | +export function partial(options: FileSizeOptionsArray): (byteCount: number) => FileSizeReturnArray |
| 61 | +export function partial(options: FileSizeOptionsExponent): (byteCount: number) => number |
| 62 | +export function partial(options: FileSizeOptionsObject): (byteCount: number) => FileSizeReturnObject |
| 63 | +export function partial(): (byteCount: number) => string |
0 commit comments