forked from avoidwork/filesize.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesize.d.ts
56 lines (48 loc) · 1.7 KB
/
filesize.d.ts
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
interface FileSizeOptionsBase {
base?: 10 | 2;
bits?: boolean;
exponent?: number;
fullform?: boolean;
fullforms?: string[];
locale?: string | boolean;
localeOptions?: Intl.DateTimeFormatOptions;
pad?: boolean;
precision?: number;
round?: number;
roundingMethod?: 'round' | 'floor' | 'ceil';
separator?: string;
spacer?: string;
standard?: 'si' | 'iec' | 'jedec';
symbols?: {};
}
interface FileSizeOptionsArray extends FileSizeOptionsBase {
output: 'array'
}
interface FileSizeOptionsExponent extends FileSizeOptionsBase {
output: 'exponent'
}
interface FileSizeOptionsObject extends FileSizeOptionsBase {
output: 'object'
}
interface FileSizeOptionsString extends FileSizeOptionsBase {
output: 'string'
}
interface FileSizeReturnObject {
value: string,
symbol: string,
exponent: number,
unit: string,
}
type FileSizeReturnArray = [ number, string ]
type FileSizeOptionStringOrBase = FileSizeOptionsString | FileSizeOptionsBase;
type FileSizeOptions = FileSizeOptionsArray | FileSizeOptionsExponent | FileSizeOptionsObject | FileSizeOptionStringOrBase | undefined
type FileSizeReturnType<Options extends FileSizeOptions> =
Options extends FileSizeOptionsArray
? FileSizeReturnArray
: Options extends FileSizeOptionsExponent
? number
: Options extends FileSizeOptionsObject
? FileSizeReturnObject
: string;
export function filesize<Options extends FileSizeOptions = undefined>(byteCount: number | string, options?: Options): FileSizeReturnType<Options>
export function partial<Options extends FileSizeOptions = undefined>(options?: Options): (byteCount: number) => FileSizeReturnType<Options>