Function parseInteger

  • Curried function to parse strings to numbers based on different radixes.

    Remarks

    Parses a string to a number with the given radix, returning undefined instead of NaN if it fails.

    Example

    const parseDecimal = parseInteger(10);

    parseDecimal("101"); // 101
    parseDecimal("101.5"); // 101
    parseDecimal("invalid"); // undefined

    See

    undefineNaN

    Parameters

    • radix: Radix

      Radix to use for parsing (16 for hexadecimal, 10 for decimal, and so on).

    Returns ((string) => Maybe<number>)

    Curried function with radix in context.

      • (string): Maybe<number>
      • Curried function with radix set.

        See

        Parameters

        • string: string

          String to parse.

        Returns Maybe<number>

        Parsed number or undefined if it fails.