Raw
1 export function trimZeros(value: string) {
2 const [whole, fraction] = value.split(".")
3
4 if (fraction) {
5 const exp = fraction.split("e")
6
7 const decimal = exp[0].replace(/0+$/, "")
8 const expStr = exp.length > 1 ? `e${exp[1]}` : ""
9
10 if (!decimal) {
11 return whole + expStr
12 }
13
14 return `${whole}.${decimal}` + expStr
15 }
16
17 return whole
18 }