Add clamp utility
This commit is contained in:
parent
90447de742
commit
7970cb64c8
1 changed files with 5 additions and 0 deletions
5
module/utils/clamp.mjs
Normal file
5
module/utils/clamp.mjs
Normal 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));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue