From bf6854993a73e94e7885b4f6022e57f238666591 Mon Sep 17 00:00:00 2001 From: dcode Date: Thu, 28 Oct 2021 09:08:27 +0200 Subject: [PATCH] Move NaN/Infinity check below unsigned setup in fromString --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e55683c..c3b437e 100644 --- a/index.js +++ b/index.js @@ -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');