math-clamp
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.2.1
    62
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.2.1
    62
  • 2.2.0
    1
  • 2.1.0
    1
  • 2.0.0
    6
  • 1.0.0
    234

Package Sidebar

Install

npm i math-clamp

Weekly Downloads

304

Version

2.2.1

License

MIT

Unpacked Size

3.44 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus