UNPKG

705 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.stringify = stringify;
7
8var _bigInt = require("./is/bigInt");
9
10// Copyright 2017-2022 @polkadot/util authors & contributors
11// SPDX-License-Identifier: Apache-2.0
12
13/** @internal */
14function replacer(_, v) {
15 return (0, _bigInt.isBigInt)(v) ? v.toString() : v;
16}
17/**
18 * @name stringify
19 * @summary Performs a JSON.stringify, with BigInt handling
20 * @description A wrapper for JSON.stringify that handles BigInt values transparently, converting them to string. No differences from the native JSON.stringify function otherwise.
21 */
22
23
24function stringify(value, space) {
25 return JSON.stringify(value, replacer, space);
26}
\No newline at end of file