pimath 0.0.106 → 0.0.107

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.
package/dist/pi.js CHANGED
@@ -4990,14 +4990,25 @@ const fraction_1 = __webpack_require__(506);
4990
4990
  class NumExp {
4991
4991
  constructor(value, uniformize) {
4992
4992
  this._expression = value;
4993
- this._rpn = new shutingyard_1.Shutingyard(shutingyard_1.ShutingyardMode.NUMERIC).parse(value, uniformize).rpn;
4993
+ try {
4994
+ this._rpn = new shutingyard_1.Shutingyard(shutingyard_1.ShutingyardMode.NUMERIC).parse(value, uniformize || uniformize === undefined).rpn;
4995
+ }
4996
+ catch (e) {
4997
+ this._rpn = null;
4998
+ this._isValid = false;
4999
+ }
4994
5000
  }
4995
5001
  get rpn() {
4996
5002
  return this._rpn;
4997
5003
  }
4998
5004
  get isValid() {
4999
5005
  if (this._isValid === undefined) {
5000
- this.evaluate({ x: 0 });
5006
+ try {
5007
+ const v = this.evaluate({ x: 0 });
5008
+ }
5009
+ catch {
5010
+ this._isValid = false;
5011
+ }
5001
5012
  }
5002
5013
  return this._isValid;
5003
5014
  }
@@ -5052,6 +5063,10 @@ class NumExp {
5052
5063
  }
5053
5064
  evaluate(values) {
5054
5065
  const stack = [];
5066
+ if (this._rpn === null) {
5067
+ this._isValid = false;
5068
+ return 0;
5069
+ }
5055
5070
  this.isValid = true;
5056
5071
  for (const element of this._rpn) {
5057
5072
  if (element.tokenType === shutingyard_1.ShutingyardType.COEFFICIENT) {