mirror of
https://github.com/rowtype-yoga/purescript-js-bigints.git
synced 2024-11-25 05:26:45 +03:00
making sure NaN is not passed to BigInt constructor
BigInt is exclusively expecting an int
This commit is contained in:
parent
feb6d4cb3a
commit
4fe2e1d2ba
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user