Skip to content

Commit

Permalink
simplify parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
emilykl committed Apr 16, 2023
1 parent 3b32d8d commit 0163281
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,9 @@ function templateFormatString(string, labels, d3locale) {
}

// Apply mult/div operation (if applicable)
if((parsedOp === '*' || parsedOp === '/') && value !== undefined) {
value = {
'*': (function(v) { return v * parsedNumber; }),
'/': (function(v) { return v / parsedNumber; }),
}[parsedOp](value);
if(value !== undefined) {
if(parsedOp === '*') value *= parsedNumber;
if(parsedOp === '/') value /= parsedNumber;
}

if(value === undefined && opts) {
Expand Down

0 comments on commit 0163281

Please sign in to comment.