Converts a numeric string to a number.

Expects the string to be a culture neutral string that can be converted to a number. Only lead negative, digits and period allowed. While parseFloat will be used, it may accept non-numeric strings like "100abc"-> 100. We are more strict here.

An empty string will return undefined.

value - expected to be a string with any text including empty string. However, only numeric strings will be converted. Integers will have Math.trunc applied. resultLookupKey = "Integer", "Number" sourceLookupKey = null or "String"

Hierarchy (view full)

Constructors

Methods

  • Determines if the value and sourceLookupKey for the result are supported by this class. This is not enough to convert, because it doesn't specify the resultLookupKey. Use canConvert() for that. Instead, this is used to export the supportedResultLookupKeys as you work through a list of close matches.

    Parameters

    • value: any
    • sourceLookupKey: null | string

    Returns boolean

  • Converts valid numeric strings and rejects non-valid ones.

    Parameters

    • value: string

      The string value to convert.

    • sourceLookupKey: null | string

      The source lookup key.

    • resultLookupKey: string

      The result lookup key.

    Returns any

    The converted number value or undefined when it is not a valid numeric string. Empty string returns undefined.

Generated using TypeDoc v0.25.12