1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 19:04:46 +00:00

refactor(packages/stdlib): add doc, update tests

This commit is contained in:
2024-04-10 17:55:08 +07:00
parent 8515bff983
commit 5280ace168
2 changed files with 45 additions and 13 deletions

View File

@@ -1,3 +1,11 @@
/**
* Clamps a number between a minimum and maximum value
*
* @param {number} value The number to clamp
* @param {number} min Minimum value
* @param {number} max Maximum value
* @returns {number} The clamped number
*/
export function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
}
}