Skip to content

Commit f2b2023

Browse files
committed
resolve #61
1 parent 2f0d425 commit f2b2023

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/util/mathWorker.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ const parseComma = function(expr){
109109
return expr.replace(/(\d+),(\d+)/g, (_, p1, p2) => `${p1}.${p2}`);
110110
};
111111

112+
/**
113+
* Parse natural logarithm (ln) to log
114+
*
115+
* @param {String} expr
116+
* @return {String}
117+
*/
118+
const parseLn = function(expr){
119+
if (!expr.includes("ln")) return expr;
120+
return expr.replace(/\bln\(/g, "log(");
121+
};
122+
112123
/**
113124
* Greatest common divisor
114125
*
@@ -327,6 +338,7 @@ function evaluateMath(expr){
327338
cleaned = parseCeil(cleaned);
328339
cleaned = parseFloor(cleaned);
329340
cleaned = parsePhi(cleaned);
341+
cleaned = parseLn(cleaned);
330342
cleaned = parseComma(cleaned);
331343

332344
let result;

0 commit comments

Comments
 (0)