Closed kricsleo closed 8 months ago
destr: 2.0.1(latest) nodejs: 18.18.1
const value = Math.random().toString() // => '0.5207845927625354' destr(value) // => '0.5207845927625354' ❌ should be number JSON.parse(value) // => 0.5207845927625354 🟢 correct
Parsing a string of numbers with more than 14 decimals gives incorrect results, it should return the number but actually returns the original string.
This should have something to do with the regex here:
https://github.com/unjs/destr/blob/37210516ccef951dcc870f17a5abee52122a3122/src/index.ts#L8
No response
Thanks for issue you are right checking docs, it seems 64bit js numbers can have up to 14 digits and 16 decimal places while regex is not allowing it. PR welcome to fix.
Environment
destr: 2.0.1(latest) nodejs: 18.18.1
Reproduction
Describe the bug
Parsing a string of numbers with more than 14 decimals gives incorrect results, it should return the number but actually returns the original string.
This should have something to do with the regex here:
https://github.com/unjs/destr/blob/37210516ccef951dcc870f17a5abee52122a3122/src/index.ts#L8
Additional context
No response
Logs
No response