MCPcopy
hub / github.com/DavidHDev/react-bits / roundToStep

Function roundToStep

src/components/common/Preview/PreviewSlider.jsx:10–14  ·  view source on GitHub ↗
(val, step, min)

Source from the content-addressed store, hash-verified

8 return dot === -1 ? 0 : s.length - dot - 1;
9};
10const roundToStep = (val, step, min) => {
11 const raw = Math.round((val - min) / step) * step + min;
12 const decimals = Math.max(stepDecimals(step), stepDecimals(min));
13 return Number(raw.toFixed(decimals));
14};
15
16const PreviewSlider = ({
17 title = '',

Callers 1

PreviewSliderFunction · 0.70

Calls 2

stepDecimalsFunction · 0.70
NumberFunction · 0.50

Tested by

no test coverage detected