clamp
Import from @varavel/vdl-plugin-sdk/utils/math.
Utility functions re-exported from es-toolkit (MIT License).
See https://github.com/toss/es-toolkit for more details.
Call Signature
Clamps a number within the inclusive upper bound.
This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound. If only one bound is provided, it returns the minimum of the value and the bound.
Parameters
| Parameter | Type | Description |
|---|---|---|
value |
number |
The number to clamp. |
maximum |
number |
The maximum bound to clamp the number. |
Returns
number
The clamped number within the specified upper bound.
Example
Call Signature
Clamps a number within the inclusive lower and upper bounds.
This function takes a number and two bounds, and returns the number clamped within the specified bounds.
Parameters
| Parameter | Type | Description |
|---|---|---|
value |
number |
The number to clamp. |
minimum |
number |
The minimum bound to clamp the number. |
maximum |
number |
The maximum bound to clamp the number. |
Returns
number
The clamped number within the specified bounds.