Skip to main content
cngx-src documentation

clamp

Functionutils

projects/utils/clamp.ts

Description#

Clamp a number into the inclusive range [min, max]. null or undefined bounds read as -Infinity / +Infinity respectively, so either side can be left open. NaN value propagates and is returned unchanged. When the bounds invert (min > max after coercion), min wins and the returned value is min.

Signature#

clamp(value: number, min, max)

Parameters#

@paramvaluenumber
@parammin
@parammax

Returns#

number