forked from visionmedia/bytes.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
34 lines (26 loc) · 952 Bytes
/
index.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
type Mode = "binary" | "metric" | "decimal" | "compatibility" | "jedec";
type BinaryUnit = "B" | "kiB" | "MiB" | "GiB" | "TiB" | "PiB" | "EiB" | "ZiB" | "YiB";
type DecimalUnit = "B" | "kB" | "MB" | "GB" | "TB" | "PB" | "EB" | "ZB" | "YB";
interface ParseOptions {
mode?: Mode;
}
declare function parse(value: number | string, options?: ParseOptions): number | null;
interface FormatOptions {
decimalPlaces?: number;
fixedDecimals?: boolean;
mode?: Mode;
thousandsSeparator?: string;
unit?: BinaryUnit | DecimalUnit;
unitSeparator?: string;
}
declare function format(value: number, options?: FormatOptions): string | null;
declare function withDefaultMode(mode: Mode): ByteConverter;
type ByteConverter = typeof format & {
format: typeof format;
parse: typeof parse;
withDefaultMode: typeof withDefaultMode;
};
declare const instance: ByteConverter;
declare module "bytes-iec" {
export = instance;
}