jty
    Preparing search index...

    Function inRangeInt

    • Checks if x is an integer and within a given range (inclusive).

      It first checks that x is an integer using isInt. If not, it returns false. Then it delegates the range checking to inRange.

      Parameters

      • x: unknown

        The integer to check.

      • Optionalmin: number

        The minimum value of the range (inclusive). If undefined, only the max is checked.

      • Optionalmax: number

        The maximum value of the range (inclusive). If undefined, only the min is checked.

      Returns x is number

      true if x is an integer and within the specified range, false otherwise.

      if either min or max are defined, but are not numbers.

      if neither min nor max are provided. Use isInt if that's what you want to do.

      inRangeInt(5, 0, 10) => true
      inRangeInt(5, 5, 10) => true
      inRangeInt(5, 0, 5) => true
      inRangeInt(5.5, 0, 10) => false