forked from iwaffles/numbro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numbro.d.ts
101 lines (84 loc) · 2.48 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
// Definitions by: Dan Poggi <https://github.com/dpoggi>
interface NumbroStatic {
(value?: any): Numbro;
version: string;
isNumbro(value: any): value is Numbro;
setCulture(newCultureCode: string, fallbackCultureCode?: string): void;
culture(): string;
culture(cultureCode: string): void;
culture(cultureCode: string, newCulture: NumbroCulture): NumbroStatic;
cultureData(cultureCode?: string): NumbroCulture;
cultures(): Array<NumbroCulture>;
/**
* Language functions
*
* @deprecated Since version 1.6.0. Will be removed in version 2.0. Use the
* culture versions instead.
*/
setLanguage(newCultureCode: string, fallbackCultureCode?: string): void;
language(): string;
language(cultureCode: string): void;
language(cultureCode: string, newCulture: NumbroCulture): NumbroStatic;
languageData(cultureCode?: string): NumbroCulture;
languages(): Array<NumbroCulture>;
zeroFormat(newFormat: string): void;
defaultFormat(newFormat: string): void;
defaultCurrencyFormat(newFormat: string): void;
validate(value: string, cultureCode?: string): boolean;
loadCulturesInNode(): void;
/**
* @deprecated Since version 1.6.0. Will be removed in version 2.0. Use the
* culture version instead.
*/
loadLanguagesInNode(): void;
}
export interface Numbro {
clone(): Numbro;
format(formatString?: string, roundingFunction?: RoundingFunction): string;
formatCurrency(formatString?: string, roundingFunction?: RoundingFunction): string;
unformat(formattedNumber: string): number;
binaryByteUnits(): string;
byteUnits(): string;
decimalByteUnits(): string;
value(): number;
valueOf(): number;
set(value: number): this;
add(value: number): this;
subtract(value: number): this;
multiply(value: number): this;
divide(value: number): this;
difference(value: number): number;
}
export interface NumbroCulture {
langLocaleCode: string;
cultureCode: string;
delimiters: {
thousands: string;
decimal: string;
};
abbreviations: {
thousand: string;
million: string;
billion: string;
trillion: string;
};
ordinal(num: number): string;
currency: {
symbol: string;
position: string;
};
defaults: {
currencyFormat: string;
};
formats: {
fourDigits: string;
fullWithTwoDecimals: string;
fullWithTwoDecimalsNoCurrency: string;
fullWithNoDecimals: string;
};
}
export interface RoundingFunction {
(x: number): number;
}
declare const numbro: NumbroStatic;
export default numbro;