forked from BenjaminVanRyseghem/numbro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumbro.d.ts
124 lines (81 loc) · 2.89 KB
/
numbro.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Definitions by: Dan Poggi <https://github.com/dpoggi>
declare function numbro(value?: any): numbro.Numbro;
declare namespace numbro {
export const version: string;
export function isNumbro(value: any): value is Numbro;
export function language(): string;
export function registerLanguage(tag: NumbroLanguage, useLanguage ?: boolean): string;
export function setLanguage(tag: string, fallbackTag ?: string): void;
export function languages(): { [tag: string]: NumbroLanguage };
export function languageData(tag ?: string): NumbroLanguage;
export function zeroFormat(newFormat: string): void;
export function defaultFormat(): {};
export function defaultCurrencyFormat(newFormat: string): {};
export function validate(value: string, format: {} | string): boolean;
export function loadLanguagesInNode(): void;
export function unformat(input: string, format?: {} | string): number;
interface Numbro {
clone(): Numbro;
format(format?: {} | string): string;
formatCurrency(format?: {} | string): string;
formatTime(format?: {} | string): string;
binaryByteUnits(): string;
decimalByteUnits(): string;
byteUnits(): string;
difference(value: number): number;
add(value: number): this;
subtract(value: number): this;
multiply(value: number): this;
divide(value: number): this;
set(value: number): this;
value(): number;
valueOf(): number;
}
interface Format {
prefix?: number;
postfix?: number;
characteristic?: number;
forceAverage?: "trillion" | "billion" | "million" | "thousand";
average?: boolean;
mantissa?: number;
optionalMantissa?: boolean;
thousandSeparated?: boolean;
negative?: "sign" | "parenthesis";
forceSign?: boolean;
totalLength?: number;
spaceSeparated?: boolean;
output?: "currency" | "percent" | "byte" | "time" | "ordinal" | "number";
}
export interface NumbroLanguage {
languageTag: string;
delimiters: {
thousands: string;
decimal: string;
};
abbreviations: {
thousand: string;
million: string;
billion: string;
trillion: string;
spaced?: boolean;
};
ordinal(num: number): string;
currency: {
symbol: string;
position: string;
code: string;
};
defaults?: Format;
ordinalFormat?: Format;
byteFormat?: Format;
percentageFormat?: Format;
currencyFormat?: Format;
formats: {
fourDigits: Format;
fullWithTwoDecimals: Format;
fullWithTwoDecimalsNoCurrency: Format;
fullWithNoDecimals: Format;
};
}
}
export = numbro;