sindresorhus / math-clamp

Clamp a number
MIT License
14 stars 3 forks source link

Allow only either `minimum` or `maximum` to be specified #8

Closed Richienb closed 10 months ago

Richienb commented 10 months ago

The use case is to decrease cognitive load.

Before:

// Clamp score to a lower bound of 0
Math.max(score, 0);

After:

mathClamp(score, {minimum: 0});