ITADN
rocktimsaikia/clamp-v2
rocktimsaikia/clamp-v2 · 文件
文件最后提交记录最后更新时间
README.md

clamp-v2

Clamp a value between two bounds.

CI npm

Installation

pnpm add clamp-v2

Usage

import clamp from "clamp-v2";

clamp(1, 5, 10); // => 5
clamp(20, 5, 10); // => 10
clamp(8, 5, 10); // => 8

API

clamp(value, min, max)

Clamp a number between two given minimum and maximum bound.

Parameters:

1. value

Type: number
The number to be clamped.

2. min

Type: number
The minimum bound.

3. max

Type: number
The maximum bound.