Skip to content

Commit c42acc0

Browse files
author
tschlechtweg
committed
remove any usage and allow passing options without output property
1 parent dea30ba commit c42acc0

File tree

1 file changed

+55
-24
lines changed

1 file changed

+55
-24
lines changed

types/filesize.d.ts

+55-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,63 @@
1-
export interface FileSizeOptions {
1+
interface FileSizeOptionsBase {
2+
base?: number;
23
bits?: boolean;
4+
exponent?: number;
5+
fullform?: boolean;
6+
fullforms?: string[];
7+
locale?: string | boolean;
8+
localeOptions?: Intl.DateTimeFormatOptions;
39
pad?: boolean;
4-
base?: number;
10+
precision?: number;
511
round?: number;
6-
locale?: string;
7-
localeOptions?: {};
12+
roundingMethod?: 'round' | 'floor' | 'ceil';
813
separator?: string;
914
spacer?: string;
10-
symbols?: {};
1115
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'
1834
}
1935

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

Comments
 (0)