Package Exports
- math-clamp-x
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (math-clamp-x) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
math-clamp-x
Clamp a number to limits.
module.exports(value, [min], max)
⇒ number
⏏
This method clamp a number to min and max limits inclusive.
Kind: Exported function
Returns: number
- The clamped number.
Throws:
RangeError
If min > max.
Param | Type | Default | Description |
---|---|---|---|
value | number |
The number to be clamped. | |
[min] | number |
0 |
The minimum number. |
max | number |
The maximum number. |
Example
import mathClamp from 'math-clamp-x';
console.log(mathClamp(-5, 3, 3)); // 3
console.log(mathClamp(0, 3, 3)); // 3
console.log(mathClamp(5, 3, 3)); // 3