Function parseInteger

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


    const parseDecimal = parseInteger(10);

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


    Curried function with radix in context.


    • radix: Radix

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

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

      • (string: string): Maybe<number>
      • Parameters

        • string: string

        Returns Maybe<number>