convnum
    Preparing search index...

    Function anyToNumber

    • Converts any string to a number

      It detects the type of any input string and converts it to a number with the most likely type

      Parameters

      • str: string

        The input string to convert (e.g., 'IV', 'twenty-one', '一百二十三', '萬億')

      Returns number

      The converted number

      Error if the type is not supported or conversion fails

      This function is a shortcut for convertFrom(str, getTypes(str)[0])

      anyToNumber('123') // returns 123
      anyToNumber('IV') // returns 4
      anyToNumber('twenty-one')