1. math-clamp
Clamp a number
math-clamp
Package: math-clamp
Created by: sindresorhus
Last modified: Sat, 03 Feb 2024 10:26:41 GMT
Version: 2.2.1
License: MIT
Downloads: 1,141
Repository: https://github.com/sindresorhus/math-clamp

Install

npm install math-clamp
yarn add math-clamp

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?})

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin