UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

26 lines (25 loc) 757 B
import { configure } from '../../safe-stable-stringify.js'; const safeStringify = configure({ maximumDepth: 15, maximumBreadth: 50, }); /** * A safe value -> JSON serializer that handles circular references and truncates the depth and * breadth of the given value's serialization. * * @category JSON : Common * @category Package : @augment-vir/common * @example * * ```ts * import {safeJsonStringify} from '@augment-vir/common'; * * safeJsonStringify({some: 'value'}); * ``` * * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export function safeJsonStringify(...params) { /* node:coverage disable: idk how to get this to return `undefined`. */ return safeStringify(...params) || ''; }