silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.18k stars 239 forks source link

Add `clamp` function #276

Open mck opened 1 year ago

mck commented 1 year ago

This commit adds a new function ´clamp´ to the codebase. The clamp function takes a minimum value, a maximum value, and a value to be clamped, and returns the clamped value. The function is useful for constraining a value to a specific range, such as limiting a user input to a certain range of values. The function has been tested with several test cases to ensure that it works correctly.