@jiminp/tooltool
    Preparing search index...

    Function clamp

    • Clamps value so that it falls within the inclusive range min ... max.

      Parameters

      • value: number

        The number to clamp.

      • min: number

        The inclusive lower bound.

      • max: number

        The inclusive upper bound.

      Returns number

      min when value is lower than min, max when it is higher than max, and the original value otherwise.

      clamp(15, 0, 10); // => 10
      clamp(-2n, -1n, 5n); // => -1n
    • Clamps value so that it falls within the inclusive range min ... max.

      Parameters

      • value: bigint

        The number to clamp.

      • min: bigint

        The inclusive lower bound.

      • max: bigint

        The inclusive upper bound.

      Returns bigint

      min when value is lower than min, max when it is higher than max, and the original value otherwise.

      clamp(15, 0, 10); // => 10
      clamp(-2n, -1n, 5n); // => -1n