Skip to content

Commit a3d0dd0

Browse files
author
tschlechtweg
committed
Tweaking types and removing any usage
1 parent c9fff4f commit a3d0dd0

File tree

2 files changed

+70
-42
lines changed

2 files changed

+70
-42
lines changed

types/constants.d.ts

+15-18
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@ export const SI_KBYTE: "kB";
1919
export const SPACE: " ";
2020
export const STRING: "string";
2121
export const ZERO: "0";
22-
export namespace STRINGS {
23-
namespace symbol {
24-
namespace iec {
25-
const bits: string[];
26-
const bytes: string[];
22+
23+
export const STRINGS: {
24+
symbol: {
25+
iec: {
26+
bits: string[],
27+
bytes: string[]
28+
},
29+
jedec: {
30+
bits: string[],
31+
bytes: string[],
2732
}
28-
namespace jedec {
29-
const bits_1: string[];
30-
export { bits_1 as bits };
31-
const bytes_1: string[];
32-
export { bytes_1 as bytes };
33-
}
34-
}
35-
namespace fullform {
36-
const iec_1: string[];
37-
export { iec_1 as iec };
38-
const jedec_1: string[];
39-
export { jedec_1 as jedec };
33+
},
34+
fullform: {
35+
iec: string[],
36+
jedec: string[]
4037
}
41-
}
38+
}

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): 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): (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)