Skip to content

Repository files navigation

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

mathClamp(3n, {max: 2n});
//=> 2n

API

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

Related

About

Clamp a number

Resources

Code of conduct

Contributing

Stars

17 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages