@sankhyalabs/core-docs 5.4.0 → 5.4.1
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/classes/NumberUtils.md +45 -8
- package/package.json +1 -1
package/classes/NumberUtils.md
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
- [getValueOrZero](NumberUtils.md#getvalueorzero)
|
20
20
|
- [keepOnlyDecimalSeparator](NumberUtils.md#keeponlydecimalseparator)
|
21
21
|
- [round](NumberUtils.md#round)
|
22
|
+
- [safeFormat](NumberUtils.md#safeformat)
|
22
23
|
- [stringToNumber](NumberUtils.md#stringtonumber)
|
23
24
|
|
24
25
|
## Constructors
|
@@ -61,7 +62,7 @@ Informo: "27.99" | Obtenho: "27,99"
|
|
61
62
|
|
62
63
|
#### Defined in
|
63
64
|
|
64
|
-
src/utils/NumberUtils.ts:
|
65
|
+
src/utils/NumberUtils.ts:186
|
65
66
|
|
66
67
|
___
|
67
68
|
|
@@ -86,13 +87,13 @@ Determina a ordem de umeros.
|
|
86
87
|
|
87
88
|
#### Defined in
|
88
89
|
|
89
|
-
src/utils/NumberUtils.ts:
|
90
|
+
src/utils/NumberUtils.ts:267
|
90
91
|
|
91
92
|
___
|
92
93
|
|
93
94
|
### format
|
94
95
|
|
95
|
-
▸ `Static` **format**(`value`, `precision`, `prettyPrecision?`): `string`
|
96
|
+
▸ `Static` **format**(`value`, `precision`, `prettyPrecision?`, `defaultValue?`): `string`
|
96
97
|
|
97
98
|
Formata o numeral com a precisão informada.
|
98
99
|
|
@@ -100,6 +101,8 @@ Formata o numeral com a precisão informada.
|
|
100
101
|
|
101
102
|
```ts
|
102
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
|
103
106
|
```
|
104
107
|
|
105
108
|
#### Parameters
|
@@ -109,6 +112,7 @@ Informado: ('10,9845444', 3, 3) | Retorna: '10,985'
|
|
109
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: ######.##). |
|
110
113
|
| `precision` | `number` | `undefined` | Quantidade de casas decimais. |
|
111
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. |
|
112
116
|
|
113
117
|
#### Returns
|
114
118
|
|
@@ -118,7 +122,7 @@ Informado: ('10,9845444', 3, 3) | Retorna: '10,985'
|
|
118
122
|
|
119
123
|
#### Defined in
|
120
124
|
|
121
|
-
src/utils/NumberUtils.ts:
|
125
|
+
src/utils/NumberUtils.ts:77
|
122
126
|
|
123
127
|
___
|
124
128
|
|
@@ -161,7 +165,7 @@ Informo: value: "30abc", defaultValue: 0 | Obtenho: 0
|
|
161
165
|
|
162
166
|
#### Defined in
|
163
167
|
|
164
|
-
src/utils/NumberUtils.ts:
|
168
|
+
src/utils/NumberUtils.ts:208
|
165
169
|
|
166
170
|
___
|
167
171
|
|
@@ -185,7 +189,7 @@ Obtém o valor ou zero, caso o valor seja inválido(NaN/undefined).
|
|
185
189
|
|
186
190
|
#### Defined in
|
187
191
|
|
188
|
-
src/utils/NumberUtils.ts:
|
192
|
+
src/utils/NumberUtils.ts:227
|
189
193
|
|
190
194
|
___
|
191
195
|
|
@@ -216,7 +220,7 @@ Informado: '95.12' | Retorna: '9512'
|
|
216
220
|
|
217
221
|
#### Defined in
|
218
222
|
|
219
|
-
src/utils/NumberUtils.ts:
|
223
|
+
src/utils/NumberUtils.ts:158
|
220
224
|
|
221
225
|
___
|
222
226
|
|
@@ -260,7 +264,40 @@ Informo: ("100.16", 3) | 100.16
|
|
260
264
|
|
261
265
|
#### Defined in
|
262
266
|
|
263
|
-
src/utils/NumberUtils.ts:
|
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
|
264
301
|
|
265
302
|
___
|
266
303
|
|