Created
January 23, 2022 03:29
-
-
Save phpsmarter/0ce199fda34777dc510b4e1e8253a956 to your computer and use it in GitHub Desktop.
钳位函数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const clamp = (x: number, min: number, max: number): number => { | |
if (x < min) | |
return min; | |
if (x > max) | |
return max; | |
return x; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment