UNPKG

659 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.stringify = void 0;
4const bigInt_js_1 = require("./is/bigInt.js");
5/** @internal */
6function replacer(_, v) {
7 return (0, bigInt_js_1.isBigInt)(v)
8 ? v.toString()
9 : v;
10}
11/**
12 * @name stringify
13 * @summary Performs a JSON.stringify, with BigInt handling
14 * @description A wrapper for JSON.stringify that handles BigInt values transparently, converting them to string. No differences from the native JSON.stringify function otherwise.
15 */
16function stringify(value, space) {
17 return JSON.stringify(value, replacer, space);
18}
19exports.stringify = stringify;