Created
October 7, 2019 20:23
-
-
Save vitaly-t/66993f5feea568f38d2152cc791d5b7c 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
// Works the same as JSON.stringify, but also handles BigInt type, | |
// using 123n format, to make sure the result is reversible: | |
function stringify(value) { | |
if (value !== undefined) { | |
return JSON.stringify(value, (_, v) => typeof v === 'bigint' ? `${v}n` : v); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment