@fw-components/formula-editor 2.0.7-formula-editor.41 → 2.0.7-formula-editor.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -201,13 +201,13 @@ export class Parser {
201
201
  operatorStack.push("(");
202
202
  }
203
203
  else if (token === ")") {
204
- while (operatorStack.top() != "(") {
204
+ while (!operatorStack.isEmpty() && operatorStack.top() != "(") {
205
205
  outputQueue.enqueue(operatorStack.pop());
206
206
  }
207
207
  operatorStack.pop();
208
208
  }
209
209
  else if (this.allowedOperators.has(token)) {
210
- while (this.allowedOperators.has(operatorStack.top()) && operatorPrecedence[token] <= operatorPrecedence[operatorStack.top()]) {
210
+ while (!operatorStack.isEmpty() && this.allowedOperators.has(operatorStack.top()) && operatorPrecedence[token] <= operatorPrecedence[operatorStack.top()]) {
211
211
  outputQueue.enqueue(operatorStack.pop());
212
212
  }
213
213
  operatorStack.push(token);
@@ -216,7 +216,7 @@ export class Parser {
216
216
  outputQueue.enqueue(token);
217
217
  }
218
218
  }
219
- while (operatorStack.top()) {
219
+ while (!operatorStack.isEmpty() && operatorStack.top()) {
220
220
  outputQueue.enqueue(operatorStack.pop());
221
221
  }
222
222
  return outputQueue;
@@ -306,7 +306,7 @@ export class Parser {
306
306
  calcStack.push(Big(numA).mul(Big(numB)));
307
307
  break;
308
308
  case "/":
309
- if (parseFloat(Big(numB).toString()) === 0) {
309
+ if (Big(numB).eq(0)) {
310
310
  calculationResult.errorString = "Division by zero encountered";
311
311
  return calculationResult;
312
312
  }
@@ -322,6 +322,10 @@ export class Parser {
322
322
  }
323
323
  }
324
324
  }
325
+ if (calcStack.isEmpty()) {
326
+ calculationResult.errorString = "Calculation error: Empty result stack";
327
+ return calculationResult;
328
+ }
325
329
  calculationResult.result = parseFloat(calcStack.top().toString());
326
330
  return calculationResult;
327
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fw-components/formula-editor",
3
- "version": "2.0.7-formula-editor.41",
3
+ "version": "2.0.7-formula-editor.42",
4
4
  "description": "A WYSIWYG type formula editor",
5
5
  "main": "dist/formula-editor/src/formula-editor.js",
6
6
  "exports": {
@@ -31,5 +31,5 @@
31
31
  "@types/big.js": "^6.1.6",
32
32
  "es-dev-server": "^2.1.0"
33
33
  },
34
- "gitHead": "c53252d71f716dfcaf8a1c1e7637f09edb715b3f"
34
+ "gitHead": "13003cbdce348fbc73c50bb9a650460f344b4b88"
35
35
  }