zarm
Version:
基于 React 的移动端UI库
7 lines • 372 B
JavaScript
import getClosestPoint from './getClosestPoint';
import getPrecision from './getPrecision';
export default function ensureValuePrecision(val, props) {
var step = props.step;
var closestPoint = Number.isFinite(getClosestPoint(val, props)) ? getClosestPoint(val, props) : 0;
return step === null ? closestPoint : parseFloat(closestPoint.toFixed(getPrecision(step)));
}