Skip to content

Commit

Permalink
Normalize formatUnits to simplified decimals.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 13, 2020
1 parent e128bfc commit 79b1da1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/units/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export function commify(value: string | number): string {

let suffix = "";
if (comps.length === 2) { suffix = "." + (comps[1] || "0"); }
while (suffix.length > 2 && suffix[suffix.length - 1] === "0") {
suffix = suffix.substring(0, suffix.length - 1);
}

const formatted = [];
while (whole.length) {
Expand Down

0 comments on commit 79b1da1

Please sign in to comment.