Clamp a number to limits.
npm install math-clamp-x href="https://travis-ci.org/Xotic750/math-clamp-x"
title="Travis status"> src="https://travis-ci.org/Xotic750/math-clamp-x.svg?branch=master"
alt="Travis status" height="18">
href="https://david-dm.org/Xotic750/math-clamp-x"
title="Dependency status"> alt="Dependency status" height="18"/>
href="https://david-dm.org/Xotic750/math-clamp-x?type=dev"
title="devDependency status"> alt="devDependency status" height="18"/>
href="https://badge.fury.io/js/math-clamp-x"
title="npm version"> alt="npm version" height="18">
href="https://www.jsdelivr.com/package/npm/math-clamp-x"
title="jsDelivr hits"> alt="jsDelivr hits" height="18">
href="https://bettercodehub.com/results/Xotic750/math-clamp-x"
title="bettercodehub score"> alt="bettercodehub score" height="18">
href="https://coveralls.io/github/Xotic750/math-clamp-x?branch=master"
title="Coverage Status"> alt="Coverage Status" height="18">
Clamp a number to limits.
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
``js
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
``