tc39 / proposal-json-parse-with-source

Proposal for extending JSON.parse to expose input source text.
https://tc39.github.io/proposal-json-parse-with-source
MIT License
213 stars 9 forks source link

Bug in `intToBigInt`? #37

Closed rauschma closed 1 year ago

rauschma commented 1 year ago
const intToBigInt = (key, val, {source}) => typeof val === "number" && val % 1 === 0 ? BigInt(source) : val;

AFAICT, this code is going to fail for (e.g.) source === '123e2':

> BigInt('123e2')
SyntaxError: Cannot convert 123e2 to a BigInt
gibson042 commented 1 year ago

intToBigInt is intended to illustrate a particular example rather than completeness, but I understand the risk of developers naïvely copying code off the Internet. Does #38 satisfy your concerns?

rauschma commented 1 year ago

Looks good, yes!