all files / addon/utils/ math.js

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13                23×      
/*
 * Clamps the input `num` between the `min` and `max` values.
 *
 * Examples:
 *   clamp(5, 0, 10) // => 5
 *   clamp(5, 7, 10) // => 7
 *   clamp(5, 0, 3) // => 3
 */
export function clamp(num, min, max) {
  return Math.max(min, Math.min(max, num));
}