Skip to content

Commit 0163281

Browse files
committed
simplify parsing logic
1 parent 3b32d8d commit 0163281

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/lib/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1177,11 +1177,9 @@ function templateFormatString(string, labels, d3locale) {
11771177
}
11781178

11791179
// Apply mult/div operation (if applicable)
1180-
if((parsedOp === '*' || parsedOp === '/') && value !== undefined) {
1181-
value = {
1182-
'*': (function(v) { return v * parsedNumber; }),
1183-
'/': (function(v) { return v / parsedNumber; }),
1184-
}[parsedOp](value);
1180+
if(value !== undefined) {
1181+
if(parsedOp === '*') value *= parsedNumber;
1182+
if(parsedOp === '/') value /= parsedNumber;
11851183
}
11861184

11871185
if(value === undefined && opts) {

0 commit comments

Comments
 (0)