Ver código fonte

Blank BigNumber dishes are now treat as NaN instead of erroring

n1474335 7 anos atrás
pai
commit
283d3e1e7b
2 arquivos alterados com 6 adições e 1 exclusões
  1. 5 1
      src/core/Dish.js
  2. 1 0
      src/core/operations/Base.js

+ 5 - 1
src/core/Dish.js

@@ -194,7 +194,11 @@ Dish.prototype.translate = function(toType) {
             this.type = Dish.ARRAY_BUFFER;
             break;
         case Dish.BIG_NUMBER:
-            this.value = new BigNumber(Utils.byteArrayToUtf8(this.value));
+            try {
+                this.value = new BigNumber(Utils.byteArrayToUtf8(this.value));
+            } catch (err) {
+                this.value = new BigNumber(NaN);
+            }
             this.type = Dish.BIG_NUMBER;
             break;
         default:

+ 1 - 0
src/core/operations/Base.js

@@ -1,4 +1,5 @@
 import BigNumber from "bignumber.js";
+
 /**
  * Numerical base operations.
  *