Skip to content

clamp

Restricts a number to a range.

Import:

import 'obsidian-test-mocks/setup';

Signature:

function clamp(value: number, min: number, max: number): number

Parameters:

Parameter Type Description
value number The number to restrict.
min number The lower bound.
max number The upper bound, which wins when min is greater than max.

Returns: number — value when it lies within the range, otherwise the nearest bound.