/math/clamp
stdClamps the given value to the given range.
Type signature
(min: number, max: number) => ((x: number) => number)
Examples
clamp(0, 10)(5);
// ⇒ 5
Try in REPL
clamp(0, 10)(-5);
// ⇒ 0
Try in REPL
clamp(0, 10)(15);
// ⇒ 10
Try in REPL
Questions
- How to clamp value to the desired range?
- How to enforce a value to be in a given range?