6 lines
162 B
TypeScript
6 lines
162 B
TypeScript
function clamp({ value, min = 0, max = 100 }: { value: number; min?: number; max?: number }) {
|
|
return Math.min(Math.max(value, min), max);
|
|
}
|
|
|
|
export { clamp };
|