Clamp a value between two bounds.
pnpm add clamp-v2
import clamp from "clamp-v2";
clamp(1, 5, 10); // => 5
clamp(20, 5, 10); // => 10
clamp(8, 5, 10); // => 8
Clamp a number between two given minimum and maximum bound.
Type:
number
The number to be clamped.
Type:
number
The minimum bound.
Type:
number
The maximum bound.