UtilOptional

clamp

Clamps a number into an inclusive [min, max] range.

Usage

import { clamp } from 'ngwr/utils';

clamp(140, 0, 100); // 100
clamp(-3, 0, 100);  // 0
clamp(42, 0, 100);  // 42

API

NameDescriptionTypeDefault
clampClamps value into the inclusive [min, max] range.(value: number, min: number, max: number) => number—

See also