This repository was archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathNumberUtil.d.ts
171 lines (171 loc) · 5.11 KB
/
NumberUtil.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
* The NumberUtil class has many helper methods to work with number data.
*
* @class NumberUtil
* @module StructureJS
* @submodule util
* @author Robert S. (www.codeBelt.com)
* @static
*/
declare class NumberUtil {
constructor();
/**
* Converts bytes into megabytes.
*
* @method bytesToMegabytes
* @param bytes {number}
* @returns {number}
* @public
* @static
* @example
*
*/
static bytesToMegabytes(bytes: number): number;
/**
* Converts centimeters into inches.
*
* @method centimeterToInch
* @param cm {number}
* @public
* @static
* @returns {number}
* @example
* NumberUtil.centimeterToInch(1);
* // 0.3937
*/
static centimeterToInch(cm: number): number;
/**
* Converts inches into centimeters.
*
* @method inchToCentimeter
* @param inch {number}
* @public
* @static
* @returns {number}
* @example
* NumberUtil.inchToCentimeter(1);
* // 2.54
*/
static inchToCentimeter(inch: number): number;
/**
* Converts feet into meters.
*
* @method feetToMeter
* @param feet {number}
* @public
* @static
* @returns {number}
* @example
* NumberUtil.feetToMeter(1);
* // 0.3048
*
*/
static feetToMeter(feet: number): number;
/**
* Converts seconds into hour, minutes, seconds.
*
* @method convertToHHMMSS
* @param seconds {number}
* @param showHours [boolean=true] By default if the time does not pass one hour it will show 00:05:34. Pass false to display the time as 05:34 until it gets pass one hour and then it will show 01:00:00
* @returns {string}
* @public
* @static
* @example
* NumberUtil.convertToHHMMSS(33333);
* // '09:15:33'
*/
static convertToHHMMSS(seconds: number, showHours?: boolean): string;
/**
* Formats a number from 0-9 to display with 2 digits.
*
* @method doubleDigitFormat
* @param num {number}
* @returns {string}
* @public
* @static
* @example
* NumberUtil.doubleDigitFormat(0);
* // '00'
*
* NumberUtil.doubleDigitFormat(5);
* // '05'
*
* NumberUtil.doubleDigitFormat(9);
* // '09'
*/
static doubleDigitFormat(num: number): string;
/**
* Formats a currency string as a number.
*
* @method unformatUnit
* @param value {string} The string currency that you want converted into a number.
* @returns {number} Returns the number value of the currency string.
* @public
* @static
* @example
* NumberUtil.unformatUnit('$1,234,567.89');
* // 1234567.89
*
* NumberUtil.unformatUnit('1.234.567,89 €');
* // 1234567.89
*
* NumberUtil.unformatUnit('$-123,456,789.99');
* // -123456789.99
*/
static unformatUnit(value: string): number;
/**
* Formats a number as a currency string.
*
* @method formatUnit
* @param value {number} The number value you want formatted.
* @param [decimalPlacement=2] {number} How many decimal placements you want to show.
* @param [decimalSeparator='.'] {string} The character you want to use as the thousands separator.
* @param [thousandsSeparator=','] {string} The character you want to use as the thousands separator.
* @param [currencySymbol=''] {string} The symbol you would like to add.
* @param [currencySymbolPlacement=0] {number} The placement of the symbol. Use 0 to place in front or 1 to place at the end.
* @returns {string} Returns the formatted currency.
* @public
* @static
* @example
* NumberUtil.formatUnit(1234567.89, 2, ".", ",", "$", 0);
* // '$1,234,567.89'
*
* NumberUtil.formatUnit(12341234.56, 2, "*", ",", " €", 1);
* // '12,341,234*56 €'
*
* NumberUtil.formatUnit(-1900.24, 1);
* // '-1,900.2'
*/
static formatUnit(value: number, decimalPlacement?: number, decimalSeparator?: string, thousandsSeparator?: string, currencySymbol?: string, currencySymbolPlacement?: number): string;
/**
* Convert Fahrenheit to Celsius.
*
* @method fahrenheitToCelsius
* @param fahrenheit {number} The fahrenheit value.
* @param decimals {number} The number of decimals.
* @return {number}
* @example
* MathUtil.fahrenheitToCelsius(32);
* // 0
*
* MathUtil.fahrenheitToCelsius(212);
* // 100
*/
static fahrenheitToCelsius(fahrenheit: number, decimals?: number): number;
/**
* Convert Celsius to Fahrenheit.
*
* @method celsiusToFahrenheit
* @param celsius {number} The celsius value.
* @param decimals {number} The number of decimals.
* @return {number}
* @example
* MathUtil.celsiusToFahrenheit(0);
* // 32
*
* MathUtil.celsiusToFahrenheit(100);
* // 212
*/
static celsiusToFahrenheit(celsius: number, decimals?: number): number;
}
export default NumberUtil;