viem
Version:
14 lines (11 loc) • 398 B
text/typescript
import type { ErrorType } from '../errors/utils.js'
export type StringifyErrorType = ErrorType
export const stringify: typeof JSON.stringify = (value, replacer, space) =>
JSON.stringify(
value,
(key, value_) => {
const value = typeof value_ === 'bigint' ? value_.toString() : value_
return typeof replacer === 'function' ? replacer(key, value) : value
},
space,
)