clipNumber<N extends num> function
N?
clipNumber<N extends num>(
- N? n,
- N min,
- N max, [
- N? def,
Clips a number n
into it's limits, min
and max
.
def
The default value if n
is null.
Implementation
N? clipNumber<N extends num>(N? n, N min, N max, [N? def]) {
n ??= def;
if (n == null) return null;
if (n < min) return min;
if (n > max) return max;
return n;
}