Add clamp utility

This commit is contained in:
Oliver 2026-04-23 17:03:15 -06:00
parent 90447de742
commit 7970cb64c8

5
module/utils/clamp.mjs Normal file
View file

@ -0,0 +1,5 @@
export function clamp(min, ideal, max) {
min ??= Number.NEGATIVE_INFINITY;
max ??= Number.POSITIVE_INFINITY;
return Math.max(min, Math.min(ideal, max));
};