clamp
Constrain a number to a min/max range.
#math
#utility
#number
export const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));
// Usageclamp(5, 0, 10); // 5clamp(-5, 0, 10); // 0clamp(15, 0, 10); // 10