UNPKG

buroventures-harald-code-core

Version:

Harald Code Core - Core functionality for AI-powered coding assistant

25 lines 799 B
/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Safely stringifies an object to JSON, handling circular references by replacing them with [Circular]. * * @param obj - The object to stringify * @param space - Optional space parameter for formatting (defaults to no formatting) * @returns JSON string with circular references replaced by [Circular] */ export function safeJsonStringify(obj, space) { const seen = new WeakSet(); return JSON.stringify(obj, (key, value) => { if (typeof value === 'object' && value !== null) { if (seen.has(value)) { return '[Circular]'; } seen.add(value); } return value; }, space); } //# sourceMappingURL=safeJsonStringify.js.map