Skip to content

Commit 6adfa17

Browse files
committed
refactor(Amount): Rewrite toString
1 parent 3feafb8 commit 6adfa17

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/structures/Amount.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,18 @@ export class Amount {
8686
.toFixed(unit.optionalDecimals ?? unit.scale)
8787
.replace(/\.?0+$/, '');
8888

89+
const baseString = `${emoji ? `${emoji} ` : ''}**${preparedValue} ${
90+
unit.singular
91+
}**`;
92+
8993
if (includeUsd && usdValue) {
9094
const displayedUsd = usdValue.lt(0.01)
9195
? usdValue.toFixed(4)
9296
: usdValue.toFixed(2);
9397

94-
return `**${emoji ? `${emoji} ` : ''} ${preparedValue} ${
95-
unit.singular
96-
} **${`(≈ $${displayedUsd})`}`;
98+
return baseString + ` (≈ $${displayedUsd})`;
9799
} else {
98-
return `**${emoji ? `${emoji} ` : ''} ${preparedValue} ${unit.singular}`;
100+
return baseString;
99101
}
100102
}
101103

0 commit comments

Comments
 (0)