@jossmac/lil-libs
    Preparing search index...

    Function clamp

    • Constrains a number to an inclusive range.

      • value: number

        Number to constrain.

      • min: number

        Lower bound (inclusive).

      • max: number

        Upper bound (inclusive).

      value when within [min, max], otherwise the nearest bound.

      clamp(5, 0, 10); // 5
      clamp(-5, 0, 10); // 0
      clamp(15, 0, 10); // 10