2 * Makes sure a value can't leave the bounds of defined
3 * min & max values. If n is larger than max or smaller
4 * than min, returns min or max respectively.
6 const clamp = (value: number, min: number, max: number) => Math.min(Math.max(min, value), max);