-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Introduce a helper function for clamping a value to a range #19617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using `Math.min`/`Math.max` or with a local helper function, which leads to some unnecessary duplication. Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/d043366d0a21f5d/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/d043366d0a21f5d/output.txt Total script time: 30.51 mins
|
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/ee1ca85a0c1f670/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/ee1ca85a0c1f670/output.txt Total script time: 11.49 mins
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you.
Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using
Math.min
/Math.max
or with a local helper function, which leads to some unnecessary duplication.Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.