Files
url_tracker_tool/node_modules/@chakra-ui/utils/dist/cjs/number.cjs
Andrei 58f8093689 Rebrand from 'Redirect Intelligence v2' to 'URL Tracker Tool V2' throughout UI
- Updated all component headers and documentation
- Changed navbar and footer branding
- Updated homepage hero badge
- Modified page title in index.html
- Simplified footer text to 'Built with ❤️'
- Consistent V2 capitalization across all references
2025-08-19 19:12:23 +00:00

50 lines
1.4 KiB
JavaScript

'use strict';
function toNumber(value) {
const num = parseFloat(value);
return typeof num !== "number" || Number.isNaN(num) ? 0 : num;
}
function toPrecision(value, precision) {
let nextValue = toNumber(value);
const scaleFactor = 10 ** (precision ?? 10);
nextValue = Math.round(nextValue * scaleFactor) / scaleFactor;
return precision ? nextValue.toFixed(precision) : nextValue.toString();
}
function countDecimalPlaces(value) {
if (!Number.isFinite(value))
return 0;
let e = 1;
let p = 0;
while (Math.round(value * e) / e !== value) {
e *= 10;
p += 1;
}
return p;
}
function valueToPercent(value, min, max) {
return (value - min) * 100 / (max - min);
}
function percentToValue(percent, min, max) {
return (max - min) * percent + min;
}
function roundValueToStep(value, from, step) {
const nextValue = Math.round((value - from) / step) * step + from;
const precision = countDecimalPlaces(step);
return toPrecision(nextValue, precision);
}
function clampValue(value, min, max) {
if (value == null)
return value;
if (max < min) {
console.warn("clamp: max cannot be less than min");
}
return Math.min(Math.max(value, min), max);
}
exports.clampValue = clampValue;
exports.countDecimalPlaces = countDecimalPlaces;
exports.percentToValue = percentToValue;
exports.roundValueToStep = roundValueToStep;
exports.toPrecision = toPrecision;
exports.valueToPercent = valueToPercent;