clamp
Clamp the input parameter num using max as the upper bound and min as the lower bound.
Added in v0.0.6
Usage
ts
import { clamp } from 'parsnip-kit'
clamp(5, 0, 10) // 5
clamp(-5, 0, 10) // 0
clamp(15, 0, 10) // 10
clamp(100) // 100API
Arguments
| Arg | Type | Optional | Default | Description |
|---|---|---|---|---|
num | number | false | undefined | The number to clamp |
min | number | true | -Infinity | The minimum |
max | number | true | Infinity | The maximum |
Returns
| Type |
|---|
number |