• Parses a string defining a number with words into its numeric value.

    Parameters

    • input: string

      The string to parse.

    Returns number

    The numeric value of the input.

    Throws

    InvalidInputError This exception is thrown if the input is invalid.

    Example

    Here are some example invocations:

    const ... = parse('twenty')
    const ... = parse('one hundred and twenty three')
    const ... = parse('one thousand, two hundred and thirty four')

    Example

    Here are some example invocations that throw an exception:

    parse('in 2 hours and 3 minutes ago')
    parse('a month in the past')