mirror of
https://github.com/vale981/tridactyl
synced 2025-03-10 12:46:38 -04:00
12 lines
278 B
TypeScript
12 lines
278 B
TypeScript
![]() |
/*
|
||
|
* Clamp a number n between two values lo, hi
|
||
|
* such that if n is in [lo, hi], we return n
|
||
|
* otherwise if n < lo, return lo
|
||
|
* else return hi.
|
||
|
*/
|
||
|
Number.prototype.clamp = function (lo: number, hi: number): number {
|
||
|
return Math.max(lo, Math.min(this, hi))
|
||
|
}
|
||
|
|
||
|
export {}
|