Created
October 7, 2019 20:28
-
-
Save vitaly-t/32bb2c3121821da6424690d5f6bcb830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse(text) { | |
return JSON.parse(text, (_, value) => { | |
if (typeof value === 'string') { | |
const m = value.match(/(-?\d+)n/); | |
if (m && m[0] === value) { | |
value = BigInt(m[1]); | |
} | |
} | |
return value; | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment