making sure NaN is not passed to BigInt constructor

BigInt is exclusively expecting an int
This commit is contained in:
Ebmtranceboy 2023-09-22 22:55:26 +02:00 committed by GitHub
parent feb6d4cb3a
commit 4fe2e1d2ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,11 +35,11 @@ export const fromStringAsImpl = function (just) {
while (i < value.length) parts.push(value.slice(i, i += size));
function f(acc, chunk) {
let n = BigInt(parseInt(chunk, radix));
let n = parseInt(chunk, radix);
if (isNaN(n)) {
throw new Error("Invalid number");
} else {
return acc * factor + n;
return acc * factor + BigInt(n);
}
};