gradum-kit - v0.1.0
    Preparing search index...

    Function trim

    • Function

      trim

      Parameters

      • value: number

        The value to clamp.

      • max: number

        Upper bound, inclusive.

      • Optionalmin: number = 0

        Lower bound, inclusive.

      • Optionalfallback: number = 0

        Returned when value is not a number.

      Returns number

      The value clamped into [min, max], or fallback if it was not a number.

      Clamp a number into a range. Anything that is not a number comes back as the fallback rather than as NaN, so it is safe to pass unvalidated input straight in. Note: the bounds are given max-first.