MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / clamp

Function clamp

src/ts-default/Components/ProfileCard/ProfileCard.tsx:36–36  ·  view source on GitHub ↗
(v: number, min = 0, max = 100)

Source from the content-addressed store, hash-verified

34} as const;
35
36const clamp = (v: number, min = 0, max = 100): number => Math.min(Math.max(v, min), max);
37const round = (v: number, precision = 3): number => parseFloat(v.toFixed(precision));
38const adjust = (v: number, fMin: number, fMax: number, tMin: number, tMax: number): number =>
39 round(tMin + ((tMax - tMin) * (v - fMin)) / (fMax - fMin));

Callers 2

setVarsFromXYFunction · 0.70
ProfileCardComponentFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected