UNPKG

509 BJavaScriptView Raw
1import { isBigInt } from './is/bigInt.js';
2/** @internal */
3function replacer(_, v) {
4 return isBigInt(v)
5 ? v.toString()
6 : v;
7}
8/**
9 * @name stringify
10 * @summary Performs a JSON.stringify, with BigInt handling
11 * @description A wrapper for JSON.stringify that handles BigInt values transparently, converting them to string. No differences from the native JSON.stringify function otherwise.
12 */
13export function stringify(value, space) {
14 return JSON.stringify(value, replacer, space);
15}