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

/math-clamp/

    Package Sidebar

    Install

    npm i math-clamp

    Weekly Downloads

    302

    Version

    2.2.1

    License

    MIT

    Unpacked Size

    3.44 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus