(require("@nginstack/engine/lib/number/parseNumber"))(value [, options])
Converte string para número.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
value |
string | String a ser convertida |
|
options |
ParseOptions |
<optional> |
Opções de parsing |
Returns:
Número convertido ou NaN se inválido
- Type
- number
Methods
-
<inner> countDigits(text, start)
-
Conta dígitos consecutivos a partir de uma posição
Parameters:
Name Type Description text
string Texto
start
number Posição inicial
Returns:
Número de dígitos
- Type
- number
-
<inner> isDigit(char)
-
Verifica se um caractere é dígito
Parameters:
Name Type Description char
string Caractere a verificar
Returns:
True se for dígito
- Type
- boolean
-
<inner> isValidGrouping(text, separator)
-
Valida padrão de agrupamento para um separador específico
Parameters:
Name Type Description text
string Texto
separator
string Separador ('.' ou ',')
Returns:
True se válido
- Type
- boolean
-
<inner> validateEnUs(text)
-
Valida número no formato en-us (ponto decimal, vírgula agrupador)
Parameters:
Name Type Description text
string Texto limpo (sem sinais)
Returns:
True se válido
- Type
- boolean
-
<inner> validatePtBr(text)
-
Valida número no formato pt-br (vírgula decimal, ponto agrupador)
Parameters:
Name Type Description text
string Texto limpo (sem sinais)
Returns:
True se válido
- Type
- boolean
Type Definitions
-
ParseOptions
-
Type:
- Object
Properties:
Name Type Argument Description locale
'pt-br' | 'en-us' <optional>
minPrecision
number <optional>
maxPrecision
number <optional>