@sankhyalabs/core-docs 0.0.0-hotfix-ga-KB-4098.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/classes/ApplicationContext.md +90 -0
- package/classes/ArrayUtils.md +99 -0
- package/classes/AuthorizedServiceCaller.md +76 -0
- package/classes/Change.md +190 -0
- package/classes/DataUnit.md +2427 -0
- package/classes/DataUnitAction.md +96 -0
- package/classes/DataUnitStorage.md +116 -0
- package/classes/DateUtils.md +327 -0
- package/classes/ElementIDUtils.md +308 -0
- package/classes/ErrorException.md +214 -0
- package/classes/ErrorTracking.md +62 -0
- package/classes/FloatingManager.md +530 -0
- package/classes/HttpProvider.md +96 -0
- package/classes/JSUtils.md +115 -0
- package/classes/MaskFormatter-1.md +347 -0
- package/classes/NumberUtils.md +335 -0
- package/classes/ObjectUtils.md +160 -0
- package/classes/OnboardingUtils.md +126 -0
- package/classes/PromiseSync.md +91 -0
- package/classes/ReadyUtil.md +115 -0
- package/classes/RequestMetadata.md +84 -0
- package/classes/SelectionInfo.md +168 -0
- package/classes/SkwHttpProvider.md +109 -0
- package/classes/StringUtils.md +562 -0
- package/classes/TimeFormatter.md +98 -0
- package/classes/UserAgentUtils.md +58 -0
- package/classes/VersionUtils.md +42 -0
- package/classes/WaitingChangeException.md +200 -0
- package/classes/WarningException.md +214 -0
- package/enums/Action.md +283 -0
- package/enums/ChangeOperation.md +52 -0
- package/enums/DataType.md +63 -0
- package/enums/DependencyType.md +41 -0
- package/enums/SelectionMode.md +30 -0
- package/enums/SortMode.md +30 -0
- package/enums/UserInterface.md +195 -0
- package/interfaces/ChildDescriptor.md +41 -0
- package/interfaces/ChildLink.md +30 -0
- package/interfaces/DUActionInterceptor.md +29 -0
- package/interfaces/ExecutionContext.md +58 -0
- package/interfaces/FieldDescriptor.md +140 -0
- package/interfaces/Filter.md +41 -0
- package/interfaces/IElementIDInfo.md +30 -0
- package/interfaces/LoadDataRequest.md +101 -0
- package/interfaces/LoadDataResponse.md +36 -0
- package/interfaces/PageRequest.md +41 -0
- package/interfaces/PaginationInfo.md +75 -0
- package/interfaces/PromiseSyncCallback.md +39 -0
- package/interfaces/QuickFilter.md +41 -0
- package/interfaces/Record.md +62 -0
- package/interfaces/SavedRecord.md +85 -0
- package/interfaces/Sort.md +41 -0
- package/interfaces/SortingProvider.md +29 -0
- package/interfaces/UnitMetadata.md +52 -0
- package/interfaces/WaitingChange.md +41 -0
- package/modules/MaskFormatter.md +37 -0
- package/modules.md +73 -0
- package/package.json +14 -0
@@ -0,0 +1,347 @@
|
|
1
|
+
[@sankhyalabs/core](../README.md) / [Exports](../modules.md) / MaskFormatter
|
2
|
+
|
3
|
+
# Class: MaskFormatter
|
4
|
+
|
5
|
+
`MaskFormatter` é usado para formatar strings. Seu comportamento
|
6
|
+
é controlado pelo formato do atributo `mask` que especifica quais
|
7
|
+
caracteres são válidos e onde devem estar posicionados, intercalando-os
|
8
|
+
com eventuais caracteres literais expressados no padrão informado.
|
9
|
+
Sua implementação é inspirada pela implementação em Java do [MaskFormatter](https://docs.oracle.com/javase/7/docs/api/javax/swing/text/MaskFormatter.html).
|
10
|
+
|
11
|
+
Para o padrão da máscara podem ser usados os seguintes caracteres especiais:
|
12
|
+
|
13
|
+
| Caractere | Comportamento |
|
14
|
+
|:---------:|-------------------------------------------------------------------------------------------------------------|
|
15
|
+
| # | Qualquer número |
|
16
|
+
| ' | "Escapa" o caractere que vem na sequência. Útil quando desejamos converter um caractere especial em literal.|
|
17
|
+
| U | Qualquer letra. Transforma letras minúsculas em maiúsculas. |
|
18
|
+
| L | Qualquer letra. Transforma letras maiúsculas em minúsculas. |
|
19
|
+
| A | Qualquer letra ou número. |
|
20
|
+
| ? | Qualquer letra. Preserva maiúsculas e minúsculas. |
|
21
|
+
| * | Qualquer caractere. |
|
22
|
+
|
23
|
+
Os demais caracteres presentes no padrão serão tratados como literais, isto é,
|
24
|
+
serão apenas inseridos naquela posição.
|
25
|
+
|
26
|
+
Quando o valor a ser formatado é menor que a máscara, um 'placeHolder'
|
27
|
+
será inserido em cada posição ausente, completando a formatação.
|
28
|
+
Por padrão será usado um espaço em branco como 'placeHolder', mas
|
29
|
+
esse valor pode ser alterado.
|
30
|
+
|
31
|
+
Por exemplo:
|
32
|
+
'''
|
33
|
+
const formatter: MaskFormatter = new MaskFormatter("###-####");
|
34
|
+
formatter.placeholder = '_';
|
35
|
+
console.log(formatter.format("123"));
|
36
|
+
'''
|
37
|
+
resultaria na string '123-____'.
|
38
|
+
|
39
|
+
##Veja mais alguns exemplos:
|
40
|
+
|Padrão |Máscara |Entrada |Saída |
|
41
|
+
|----------------|------------------|--------------|------------------|
|
42
|
+
|Telefone |(##) ####-#### |3432192515 |(34) 3219-2515 |
|
43
|
+
|CPF |###.###.###-## |12345678901 |123.456.789-01 |
|
44
|
+
|CNPJ |##.###.###/####-##|12345678901234|12.345.678/9012-34|
|
45
|
+
|CEP |##.###-### |12345678 |12.345-678 |
|
46
|
+
|PLACA (veículo) |UUU-#### |abc1234 |ABC-1234 |
|
47
|
+
|Cor RGB |'#AAAAAA |00000F0 |#0000F0 |
|
48
|
+
|
49
|
+
## Table of contents
|
50
|
+
|
51
|
+
### Constructors
|
52
|
+
|
53
|
+
- [constructor](MaskFormatter-1.md#constructor)
|
54
|
+
|
55
|
+
### Properties
|
56
|
+
|
57
|
+
- [\_mask](MaskFormatter-1.md#_mask)
|
58
|
+
- [\_maskChars](MaskFormatter-1.md#_maskchars)
|
59
|
+
- [placeholder](MaskFormatter-1.md#placeholder)
|
60
|
+
- [ALPHA\_NUMERIC\_KEY](MaskFormatter-1.md#alpha_numeric_key)
|
61
|
+
- [ANYTHING\_KEY](MaskFormatter-1.md#anything_key)
|
62
|
+
- [AlphaNumericCharacter](MaskFormatter-1.md#alphanumericcharacter)
|
63
|
+
- [CHARACTER\_KEY](MaskFormatter-1.md#character_key)
|
64
|
+
- [CharCharacter](MaskFormatter-1.md#charcharacter)
|
65
|
+
- [DEFAULT\_MASKS](MaskFormatter-1.md#default_masks)
|
66
|
+
- [DIGIT\_KEY](MaskFormatter-1.md#digit_key)
|
67
|
+
- [DigitMaskCharacter](MaskFormatter-1.md#digitmaskcharacter)
|
68
|
+
- [LITERAL\_KEY](MaskFormatter-1.md#literal_key)
|
69
|
+
- [LOWERCASE\_KEY](MaskFormatter-1.md#lowercase_key)
|
70
|
+
- [LiteralCharacter](MaskFormatter-1.md#literalcharacter)
|
71
|
+
- [LowerCaseCharacter](MaskFormatter-1.md#lowercasecharacter)
|
72
|
+
- [UPPERCASE\_KEY](MaskFormatter-1.md#uppercase_key)
|
73
|
+
- [UpperCaseCharacter](MaskFormatter-1.md#uppercasecharacter)
|
74
|
+
|
75
|
+
### Accessors
|
76
|
+
|
77
|
+
- [mask](MaskFormatter-1.md#mask)
|
78
|
+
|
79
|
+
### Methods
|
80
|
+
|
81
|
+
- [format](MaskFormatter-1.md#format)
|
82
|
+
- [updateInternalMask](MaskFormatter-1.md#updateinternalmask)
|
83
|
+
|
84
|
+
## Constructors
|
85
|
+
|
86
|
+
### constructor
|
87
|
+
|
88
|
+
• **new MaskFormatter**(`mask`)
|
89
|
+
|
90
|
+
#### Parameters
|
91
|
+
|
92
|
+
| Name | Type |
|
93
|
+
| :------ | :------ |
|
94
|
+
| `mask` | `string` |
|
95
|
+
|
96
|
+
#### Defined in
|
97
|
+
|
98
|
+
src/utils/MaskFormatter.ts:91
|
99
|
+
|
100
|
+
## Properties
|
101
|
+
|
102
|
+
### \_mask
|
103
|
+
|
104
|
+
• `Private` **\_mask**: `string` = `''`
|
105
|
+
|
106
|
+
#### Defined in
|
107
|
+
|
108
|
+
src/utils/MaskFormatter.ts:65
|
109
|
+
|
110
|
+
___
|
111
|
+
|
112
|
+
### \_maskChars
|
113
|
+
|
114
|
+
• `Private` **\_maskChars**: `__class`[]
|
115
|
+
|
116
|
+
#### Defined in
|
117
|
+
|
118
|
+
src/utils/MaskFormatter.ts:66
|
119
|
+
|
120
|
+
___
|
121
|
+
|
122
|
+
### placeholder
|
123
|
+
|
124
|
+
• **placeholder**: `string` = `' '`
|
125
|
+
|
126
|
+
Determina qual caractere será usado dos caracteres não presentes no valor,
|
127
|
+
ou seja, aqueles que o usuário ainda não informou. Por padrão usamos um espaço.
|
128
|
+
|
129
|
+
#### Defined in
|
130
|
+
|
131
|
+
src/utils/MaskFormatter.ts:72
|
132
|
+
|
133
|
+
___
|
134
|
+
|
135
|
+
### ALPHA\_NUMERIC\_KEY
|
136
|
+
|
137
|
+
▪ `Static` `Private` **ALPHA\_NUMERIC\_KEY**: `string` = `"A"`
|
138
|
+
|
139
|
+
#### Defined in
|
140
|
+
|
141
|
+
src/utils/MaskFormatter.ts:53
|
142
|
+
|
143
|
+
___
|
144
|
+
|
145
|
+
### ANYTHING\_KEY
|
146
|
+
|
147
|
+
▪ `Static` `Private` **ANYTHING\_KEY**: `string` = `"*"`
|
148
|
+
|
149
|
+
#### Defined in
|
150
|
+
|
151
|
+
src/utils/MaskFormatter.ts:55
|
152
|
+
|
153
|
+
___
|
154
|
+
|
155
|
+
### AlphaNumericCharacter
|
156
|
+
|
157
|
+
▪ `Static` `Private` **AlphaNumericCharacter**: typeof `__class`
|
158
|
+
|
159
|
+
#### Defined in
|
160
|
+
|
161
|
+
src/utils/MaskFormatter.ts:375
|
162
|
+
|
163
|
+
___
|
164
|
+
|
165
|
+
### CHARACTER\_KEY
|
166
|
+
|
167
|
+
▪ `Static` `Private` **CHARACTER\_KEY**: `string` = `"?"`
|
168
|
+
|
169
|
+
#### Defined in
|
170
|
+
|
171
|
+
src/utils/MaskFormatter.ts:54
|
172
|
+
|
173
|
+
___
|
174
|
+
|
175
|
+
### CharCharacter
|
176
|
+
|
177
|
+
▪ `Static` `Private` **CharCharacter**: typeof `__class`
|
178
|
+
|
179
|
+
#### Defined in
|
180
|
+
|
181
|
+
src/utils/MaskFormatter.ts:389
|
182
|
+
|
183
|
+
___
|
184
|
+
|
185
|
+
### DEFAULT\_MASKS
|
186
|
+
|
187
|
+
▪ `Static` **DEFAULT\_MASKS**: `any`
|
188
|
+
|
189
|
+
#### Defined in
|
190
|
+
|
191
|
+
src/utils/MaskFormatter.ts:57
|
192
|
+
|
193
|
+
___
|
194
|
+
|
195
|
+
### DIGIT\_KEY
|
196
|
+
|
197
|
+
▪ `Static` `Private` **DIGIT\_KEY**: `string` = `"#"`
|
198
|
+
|
199
|
+
#### Defined in
|
200
|
+
|
201
|
+
src/utils/MaskFormatter.ts:49
|
202
|
+
|
203
|
+
___
|
204
|
+
|
205
|
+
### DigitMaskCharacter
|
206
|
+
|
207
|
+
▪ `Static` `Private` **DigitMaskCharacter**: typeof `__class`
|
208
|
+
|
209
|
+
#### Defined in
|
210
|
+
|
211
|
+
src/utils/MaskFormatter.ts:300
|
212
|
+
|
213
|
+
___
|
214
|
+
|
215
|
+
### LITERAL\_KEY
|
216
|
+
|
217
|
+
▪ `Static` `Private` **LITERAL\_KEY**: `string` = `"'"`
|
218
|
+
|
219
|
+
#### Defined in
|
220
|
+
|
221
|
+
src/utils/MaskFormatter.ts:50
|
222
|
+
|
223
|
+
___
|
224
|
+
|
225
|
+
### LOWERCASE\_KEY
|
226
|
+
|
227
|
+
▪ `Static` `Private` **LOWERCASE\_KEY**: `string` = `"L"`
|
228
|
+
|
229
|
+
#### Defined in
|
230
|
+
|
231
|
+
src/utils/MaskFormatter.ts:52
|
232
|
+
|
233
|
+
___
|
234
|
+
|
235
|
+
### LiteralCharacter
|
236
|
+
|
237
|
+
▪ `Static` `Private` **LiteralCharacter**: typeof `__class`
|
238
|
+
|
239
|
+
#### Defined in
|
240
|
+
|
241
|
+
src/utils/MaskFormatter.ts:281
|
242
|
+
|
243
|
+
___
|
244
|
+
|
245
|
+
### LowerCaseCharacter
|
246
|
+
|
247
|
+
▪ `Static` `Private` **LowerCaseCharacter**: typeof `__class`
|
248
|
+
|
249
|
+
#### Defined in
|
250
|
+
|
251
|
+
src/utils/MaskFormatter.ts:352
|
252
|
+
|
253
|
+
___
|
254
|
+
|
255
|
+
### UPPERCASE\_KEY
|
256
|
+
|
257
|
+
▪ `Static` `Private` **UPPERCASE\_KEY**: `string` = `"U"`
|
258
|
+
|
259
|
+
#### Defined in
|
260
|
+
|
261
|
+
src/utils/MaskFormatter.ts:51
|
262
|
+
|
263
|
+
___
|
264
|
+
|
265
|
+
### UpperCaseCharacter
|
266
|
+
|
267
|
+
▪ `Static` `Private` **UpperCaseCharacter**: typeof `__class`
|
268
|
+
|
269
|
+
#### Defined in
|
270
|
+
|
271
|
+
src/utils/MaskFormatter.ts:329
|
272
|
+
|
273
|
+
## Accessors
|
274
|
+
|
275
|
+
### mask
|
276
|
+
|
277
|
+
• `get` **mask**(): `string`
|
278
|
+
|
279
|
+
Getter para mask.
|
280
|
+
|
281
|
+
#### Returns
|
282
|
+
|
283
|
+
`string`
|
284
|
+
|
285
|
+
A última máscara informada.
|
286
|
+
|
287
|
+
#### Defined in
|
288
|
+
|
289
|
+
src/utils/MaskFormatter.ts:87
|
290
|
+
|
291
|
+
• `set` **mask**(`mask`): `void`
|
292
|
+
|
293
|
+
Setter para mask. Trata-se do padrão que se espera ao formatar o texto.
|
294
|
+
|
295
|
+
#### Parameters
|
296
|
+
|
297
|
+
| Name | Type |
|
298
|
+
| :------ | :------ |
|
299
|
+
| `mask` | `string` |
|
300
|
+
|
301
|
+
#### Returns
|
302
|
+
|
303
|
+
`void`
|
304
|
+
|
305
|
+
#### Defined in
|
306
|
+
|
307
|
+
src/utils/MaskFormatter.ts:77
|
308
|
+
|
309
|
+
## Methods
|
310
|
+
|
311
|
+
### format
|
312
|
+
|
313
|
+
▸ **format**(`value`): `string`
|
314
|
+
|
315
|
+
Formata a string passada baseada na máscara definda pelo atributo mask.
|
316
|
+
|
317
|
+
#### Parameters
|
318
|
+
|
319
|
+
| Name | Type | Description |
|
320
|
+
| :------ | :------ | :------ |
|
321
|
+
| `value` | `string` | Valor a ser formatado. |
|
322
|
+
|
323
|
+
#### Returns
|
324
|
+
|
325
|
+
`string`
|
326
|
+
|
327
|
+
O valor processado de acordo com o padrão.
|
328
|
+
|
329
|
+
#### Defined in
|
330
|
+
|
331
|
+
src/utils/MaskFormatter.ts:101
|
332
|
+
|
333
|
+
___
|
334
|
+
|
335
|
+
### updateInternalMask
|
336
|
+
|
337
|
+
▸ `Private` **updateInternalMask**(): `void`
|
338
|
+
|
339
|
+
Prepara a formatação internamente de acordo com o padrão.
|
340
|
+
|
341
|
+
#### Returns
|
342
|
+
|
343
|
+
`void`
|
344
|
+
|
345
|
+
#### Defined in
|
346
|
+
|
347
|
+
src/utils/MaskFormatter.ts:118
|
@@ -0,0 +1,335 @@
|
|
1
|
+
[@sankhyalabs/core](../README.md) / [Exports](../modules.md) / NumberUtils
|
2
|
+
|
3
|
+
# Class: NumberUtils
|
4
|
+
|
5
|
+
`NumberUtils`: Utilizado para manipulação de numerais.
|
6
|
+
|
7
|
+
## Table of contents
|
8
|
+
|
9
|
+
### Constructors
|
10
|
+
|
11
|
+
- [constructor](NumberUtils.md#constructor)
|
12
|
+
|
13
|
+
### Methods
|
14
|
+
|
15
|
+
- [changeFormat](NumberUtils.md#changeformat)
|
16
|
+
- [compare](NumberUtils.md#compare)
|
17
|
+
- [format](NumberUtils.md#format)
|
18
|
+
- [getValueOrDefault](NumberUtils.md#getvalueordefault)
|
19
|
+
- [getValueOrZero](NumberUtils.md#getvalueorzero)
|
20
|
+
- [keepOnlyDecimalSeparator](NumberUtils.md#keeponlydecimalseparator)
|
21
|
+
- [round](NumberUtils.md#round)
|
22
|
+
- [safeFormat](NumberUtils.md#safeformat)
|
23
|
+
- [stringToNumber](NumberUtils.md#stringtonumber)
|
24
|
+
|
25
|
+
## Constructors
|
26
|
+
|
27
|
+
### constructor
|
28
|
+
|
29
|
+
• **new NumberUtils**()
|
30
|
+
|
31
|
+
## Methods
|
32
|
+
|
33
|
+
### changeFormat
|
34
|
+
|
35
|
+
▸ `Static` **changeFormat**(`value`): `string`
|
36
|
+
|
37
|
+
Troca o formato do numeral(string) de "PT-BR" para "EN-US" e vice-versa.
|
38
|
+
|
39
|
+
**`Example`**
|
40
|
+
|
41
|
+
```ts
|
42
|
+
Informo: "15,55" | Obtenho: "15.55"
|
43
|
+
```
|
44
|
+
|
45
|
+
**`Example`**
|
46
|
+
|
47
|
+
```ts
|
48
|
+
Informo: "27.99" | Obtenho: "27,99"
|
49
|
+
```
|
50
|
+
|
51
|
+
#### Parameters
|
52
|
+
|
53
|
+
| Name | Type | Description |
|
54
|
+
| :------ | :------ | :------ |
|
55
|
+
| `value` | `string` | Numeral em formato de string a ser convertido. |
|
56
|
+
|
57
|
+
#### Returns
|
58
|
+
|
59
|
+
`string`
|
60
|
+
|
61
|
+
- Numeral em formato de string formatado de "PT-BR" para "EN-US" e vice-versa.
|
62
|
+
|
63
|
+
#### Defined in
|
64
|
+
|
65
|
+
src/utils/NumberUtils.ts:186
|
66
|
+
|
67
|
+
___
|
68
|
+
|
69
|
+
### compare
|
70
|
+
|
71
|
+
▸ `Static` **compare**(`a`, `b`): `number`
|
72
|
+
|
73
|
+
Determina a ordem de umeros.
|
74
|
+
|
75
|
+
#### Parameters
|
76
|
+
|
77
|
+
| Name | Type | Description |
|
78
|
+
| :------ | :------ | :------ |
|
79
|
+
| `a` | `number` | Primeio número para comparação. |
|
80
|
+
| `b` | `number` | Segundo número para comparação. |
|
81
|
+
|
82
|
+
#### Returns
|
83
|
+
|
84
|
+
`number`
|
85
|
+
|
86
|
+
- Um numeral negativo se o primeiro argumento é menor que o segundo, zero se os dois são iguais e um numeral positivo quando o primeiro é maior que o segundo.
|
87
|
+
|
88
|
+
#### Defined in
|
89
|
+
|
90
|
+
src/utils/NumberUtils.ts:267
|
91
|
+
|
92
|
+
___
|
93
|
+
|
94
|
+
### format
|
95
|
+
|
96
|
+
▸ `Static` **format**(`value`, `precision`, `prettyPrecision?`, `defaultValue?`): `string`
|
97
|
+
|
98
|
+
Formata o numeral com a precisão informada.
|
99
|
+
|
100
|
+
**`Example`**
|
101
|
+
|
102
|
+
```ts
|
103
|
+
Informado: ('10,9845444', 3, 3) | Retorna: '10,985'
|
104
|
+
Informado: (undefined, 3, 3) | Retorna: NaN
|
105
|
+
Informado: (undefined, 3, 3, '0,00') | Retorna: 0,00
|
106
|
+
```
|
107
|
+
|
108
|
+
#### Parameters
|
109
|
+
|
110
|
+
| Name | Type | Default value | Description |
|
111
|
+
| :------ | :------ | :------ | :------ |
|
112
|
+
| `value` | `string` | `undefined` | Numeral em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico - sem separador de milhares: ######.##). |
|
113
|
+
| `precision` | `number` | `undefined` | Quantidade de casas decimais. |
|
114
|
+
| `prettyPrecision` | `number` | `NaN` | Quantidade de zeros nos decimais. |
|
115
|
+
| `defaultValue` | `string` | `undefined` | Valor padrão caso o value não seja um valor numérico válido. |
|
116
|
+
|
117
|
+
#### Returns
|
118
|
+
|
119
|
+
`string`
|
120
|
+
|
121
|
+
- Numeral em formato de String formatado em PT-BR.
|
122
|
+
|
123
|
+
#### Defined in
|
124
|
+
|
125
|
+
src/utils/NumberUtils.ts:77
|
126
|
+
|
127
|
+
___
|
128
|
+
|
129
|
+
### getValueOrDefault
|
130
|
+
|
131
|
+
▸ `Static` **getValueOrDefault**(`value`, `defaultValue`): `number`
|
132
|
+
|
133
|
+
Obtém o valor ou o valor padrão, caso o valor seja inválido(NaN/undefined).
|
134
|
+
|
135
|
+
**`Example`**
|
136
|
+
|
137
|
+
```ts
|
138
|
+
Informo: value: 30, defaultValue: 0 | Obtenho: 30
|
139
|
+
```
|
140
|
+
|
141
|
+
**`Example`**
|
142
|
+
|
143
|
+
```ts
|
144
|
+
Informo: value: "30", defaultValue: 0 | Obtenho: 30
|
145
|
+
```
|
146
|
+
|
147
|
+
**`Example`**
|
148
|
+
|
149
|
+
```ts
|
150
|
+
Informo: value: "30abc", defaultValue: 0 | Obtenho: 0
|
151
|
+
```
|
152
|
+
|
153
|
+
#### Parameters
|
154
|
+
|
155
|
+
| Name | Type | Description |
|
156
|
+
| :------ | :------ | :------ |
|
157
|
+
| `value` | `any` | Valor a ser validado. |
|
158
|
+
| `defaultValue` | `number` | Valor padrão a ser retornado caso o value seja inválido. |
|
159
|
+
|
160
|
+
#### Returns
|
161
|
+
|
162
|
+
`number`
|
163
|
+
|
164
|
+
- O próprio numeral passado ou zero.
|
165
|
+
|
166
|
+
#### Defined in
|
167
|
+
|
168
|
+
src/utils/NumberUtils.ts:208
|
169
|
+
|
170
|
+
___
|
171
|
+
|
172
|
+
### getValueOrZero
|
173
|
+
|
174
|
+
▸ `Static` **getValueOrZero**(`value`): `number`
|
175
|
+
|
176
|
+
Obtém o valor ou zero, caso o valor seja inválido(NaN/undefined).
|
177
|
+
|
178
|
+
#### Parameters
|
179
|
+
|
180
|
+
| Name | Type | Description |
|
181
|
+
| :------ | :------ | :------ |
|
182
|
+
| `value` | `any` | Numeral a ser validado. |
|
183
|
+
|
184
|
+
#### Returns
|
185
|
+
|
186
|
+
`number`
|
187
|
+
|
188
|
+
- O próprio numeral passado. Caso esse seja inválido retorna zero.
|
189
|
+
|
190
|
+
#### Defined in
|
191
|
+
|
192
|
+
src/utils/NumberUtils.ts:227
|
193
|
+
|
194
|
+
___
|
195
|
+
|
196
|
+
### keepOnlyDecimalSeparator
|
197
|
+
|
198
|
+
▸ `Static` **keepOnlyDecimalSeparator**(`value`, `formatnumber?`): `string`
|
199
|
+
|
200
|
+
Retira os separadores de milhar de um numeral em formato de string.
|
201
|
+
|
202
|
+
**`Example`**
|
203
|
+
|
204
|
+
```ts
|
205
|
+
Informado: '95.12' | Retorna: '9512'
|
206
|
+
```
|
207
|
+
|
208
|
+
#### Parameters
|
209
|
+
|
210
|
+
| Name | Type | Default value | Description |
|
211
|
+
| :------ | :------ | :------ | :------ |
|
212
|
+
| `value` | `string` | `undefined` | Numeral em formato de string a ser convertido. |
|
213
|
+
| `formatnumber` | `string` | `'pt-BR'` | Formatação de ENTRADA e SAÍDA do utilitário: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR". |
|
214
|
+
|
215
|
+
#### Returns
|
216
|
+
|
217
|
+
`string`
|
218
|
+
|
219
|
+
- Numeral em formato de string formatado apenas com separador decimal.
|
220
|
+
|
221
|
+
#### Defined in
|
222
|
+
|
223
|
+
src/utils/NumberUtils.ts:158
|
224
|
+
|
225
|
+
___
|
226
|
+
|
227
|
+
### round
|
228
|
+
|
229
|
+
▸ `Static` **round**(`value`, `decimals?`): `number`
|
230
|
+
|
231
|
+
Realiza o arredondamento de casas decimais de um numero.
|
232
|
+
|
233
|
+
**`Example`**
|
234
|
+
|
235
|
+
```ts
|
236
|
+
Informo: (100.12) | 100.12
|
237
|
+
Informo: (100,12) | NaN
|
238
|
+
|
239
|
+
Informo: ("100.12", 1) | 100.1
|
240
|
+
Informo: ("100.12", 2) | 100.12
|
241
|
+
Informo: ("100.12", 3) | 100.12
|
242
|
+
|
243
|
+
Informo: ("100.15", 1) | 100.2
|
244
|
+
Informo: ("100.15", 2) | 100.15
|
245
|
+
Informo: ("100.15", 3) | 100.15
|
246
|
+
|
247
|
+
Informo: ("100.16", 1) | 100.2
|
248
|
+
Informo: ("100.16", 2) | 100.16
|
249
|
+
Informo: ("100.16", 3) | 100.16
|
250
|
+
```
|
251
|
+
|
252
|
+
#### Parameters
|
253
|
+
|
254
|
+
| Name | Type | Default value | Description |
|
255
|
+
| :------ | :------ | :------ | :------ |
|
256
|
+
| `value` | `number` | `undefined` | Numeral a ser arredondado. |
|
257
|
+
| `decimals` | `number` | `2` | Quantidade de casas decimais ussada no arredondamento. |
|
258
|
+
|
259
|
+
#### Returns
|
260
|
+
|
261
|
+
`number`
|
262
|
+
|
263
|
+
- O próprio numeral arredondado com a quantidade de casas decimais do argumento decimals.
|
264
|
+
|
265
|
+
#### Defined in
|
266
|
+
|
267
|
+
src/utils/NumberUtils.ts:255
|
268
|
+
|
269
|
+
___
|
270
|
+
|
271
|
+
### safeFormat
|
272
|
+
|
273
|
+
▸ `Static` **safeFormat**(`value`, `precision`, `prettyPrecision?`): `string`
|
274
|
+
|
275
|
+
Formata o numeral com a precisão informada e o valor default 0,00 caso o value não seja um numero valido.
|
276
|
+
|
277
|
+
**`Example`**
|
278
|
+
|
279
|
+
```ts
|
280
|
+
Informado: ('10,9845444', 3, 3) | Retorna: '10,985'
|
281
|
+
Informado: (undefined, 3, 3) | Retorna: 0,00
|
282
|
+
```
|
283
|
+
|
284
|
+
#### Parameters
|
285
|
+
|
286
|
+
| Name | Type | Default value | Description |
|
287
|
+
| :------ | :------ | :------ | :------ |
|
288
|
+
| `value` | `string` | `undefined` | Numeral em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico - sem separador de milhares: ######.##). |
|
289
|
+
| `precision` | `number` | `undefined` | Quantidade de casas decimais. |
|
290
|
+
| `prettyPrecision` | `number` | `NaN` | Quantidade de zeros nos decimais. |
|
291
|
+
|
292
|
+
#### Returns
|
293
|
+
|
294
|
+
`string`
|
295
|
+
|
296
|
+
- Numeral em formato de String formatado em PT-BR.
|
297
|
+
|
298
|
+
#### Defined in
|
299
|
+
|
300
|
+
src/utils/NumberUtils.ts:143
|
301
|
+
|
302
|
+
___
|
303
|
+
|
304
|
+
### stringToNumber
|
305
|
+
|
306
|
+
▸ `Static` **stringToNumber**(`value`): `number`
|
307
|
+
|
308
|
+
Converte o dado numérico de string para number.
|
309
|
+
|
310
|
+
**`Example`**
|
311
|
+
|
312
|
+
```ts
|
313
|
+
@"100,12" | 100.12
|
314
|
+
@"100.12" | 100.12
|
315
|
+
@"-100,12" | -100.12
|
316
|
+
@"R$100,12" | 100.12
|
317
|
+
@"-R$100,12" | -100.12
|
318
|
+
@"string" | NaN
|
319
|
+
```
|
320
|
+
|
321
|
+
#### Parameters
|
322
|
+
|
323
|
+
| Name | Type | Description |
|
324
|
+
| :------ | :------ | :------ |
|
325
|
+
| `value` | `string` | Numeral em formato de string a ser convertido (Importante: formato PT-BR ou já em formato numérico: ######.##). |
|
326
|
+
|
327
|
+
#### Returns
|
328
|
+
|
329
|
+
`number`
|
330
|
+
|
331
|
+
- Numeral passado.
|
332
|
+
|
333
|
+
#### Defined in
|
334
|
+
|
335
|
+
src/utils/NumberUtils.ts:22
|