teoldalad/lib/utils.ts
2024-03-13 00:30:45 +01:00

10 lines
No EOL
308 B
TypeScript

export const getRandomInt = (min: number, max: number) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
export const clamp = (value: number, min: number, max: number) => {
return Math.min(Math.max(value, min), max);
};