(json: string)
| 19 | * Objects with __type: 'bigint' are converted back to BigInt |
| 20 | */ |
| 21 | export function parseWithBigInt(json: string): any { |
| 22 | return JSON.parse(json, (_key, value) => { |
| 23 | if ( |
| 24 | value && |
| 25 | typeof value === 'object' && |
| 26 | value.__type === 'bigint' && |
| 27 | typeof value.value === 'string' |
| 28 | ) { |
| 29 | return BigInt(value.value) |
| 30 | } |
| 31 | return value |
| 32 | }) |
| 33 | } |
no outgoing calls
no test coverage detected