math-clamp

Clamp a number


Keywords
math, number, numbers, clamp, limit, min, max, minimum, maximum, between, range
License
MIT
Install
npm install math-clamp@2.2.1

Documentation

math-clamp

Clamp a number

Install

npm install math-clamp

Usage

import mathClamp from 'math-clamp';

mathClamp(1, {min: 2, max: 4});
//=> 2

mathClamp(1, {min: 2});
//=> 2

mathClamp(5, {max: 4});
//=> 4

API

mathClamp(number, {min?, max?})

Related