hughsk

hughsk/clamp

Clamp a value between two other values.

JavaScript
39
5
MIT License

clamp is a JavaScript module that restricts a value to be within a specified range, returning the value if it falls between the bounds or the nearest bound if it doesn't. It's designed for developers who frequently need to constrain numeric values in their code, saving them from repeatedly writing the same utility function. The module is simple, lightweight, and licensed under MIT, making it easy to integrate into projects.

Total donated
Undistributed
Share with your subscribers: