Skip to content

Commit

Permalink
Move NaN/Infinity check below unsigned setup in fromString
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Oct 28, 2021
1 parent 19ac17b commit bf68549
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -235,15 +235,15 @@ var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
function fromString(str, unsigned, radix) {
if (str.length === 0)
throw Error('empty string');
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
return unsigned ? UZERO : ZERO;
if (typeof unsigned === 'number') {
// For goog.math.long compatibility
radix = unsigned,
unsigned = false;
radix = unsigned;
unsigned = false;
} else {
unsigned = !!unsigned;
}
if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
return unsigned ? UZERO : ZERO;
radix = radix || 10;
if (radix < 2 || 36 < radix)
throw RangeError('radix');
Expand Down

0 comments on commit bf68549

Please sign in to comment.