16 lines
359 B
JavaScript
16 lines
359 B
JavaScript
export function formatCurrency(value) {
|
|
return `¥${Number(value || 0).toFixed(2)}`
|
|
}
|
|
|
|
function toPercentNumber(value) {
|
|
return Math.max(0, Math.round((Number(value) || 0) * 100))
|
|
}
|
|
|
|
export function formatPercent(value) {
|
|
return `${toPercentNumber(value)}%`
|
|
}
|
|
|
|
export function clampPercent(value) {
|
|
return `${Math.min(100, toPercentNumber(value))}%`
|
|
}
|