clamp<T extends num> static method

T clamp<T extends num>(
  1. T n,
  2. T min,
  3. T max
)

Returns n bounded into the inclusive range min to max.

Implementation

static T clamp<T extends num>(T n, T min, T max) =>
    n < min ? min : (n > max ? max : n);