UNPKG

591 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { isBigInt } from "./is/bigInt.js";
4/** @internal */
5
6function replacer(_, v) {
7 return isBigInt(v) ? v.toString() : v;
8}
9/**
10 * @name stringify
11 * @summary Performs a JSON.stringify, with BigInt handling
12 * @description A wrapper for JSON.stringify that handles BigInt values transparently, converting them to string. No differences from the native JSON.stringify function otherwise.
13 */
14
15
16export function stringify(value, space) {
17 return JSON.stringify(value, replacer, space);
18}
\No newline at end of file