mirror of
https://github.com/encounter/decomp.dev.git
synced 2026-07-10 03:18:48 -07:00
Don't round partially-matched percentages to 0.00% or 100.00% (#8)
* Don't round percentages to 0.00% or 100.00% * Remove dead code
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
export function clamp(value: number, min: number, max: number) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
// Formats a progress percentage as a string, and prevents partial matches from being rounded to 0.00% or 100.00%.
|
||||
export function formatPercent(value: number) {
|
||||
if (value !== 0.0 && value !== 100.0) {
|
||||
value = clamp(value, 0.01, 99.99);
|
||||
}
|
||||
return `${value.toFixed(2)}%`;
|
||||
}
|
||||
Reference in New Issue
Block a user