clamp

clamp

Clamps a number between two values

Import

import { clamp } from '@fullstacksjs/toolbox';

Signature

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

Examples

clamp(5, 0, 100)   // 5
clamp(-10, 0, 100) // 0
clamp(101, 0, 100) // 100