UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

38 lines 1.59 kB
export declare class JsonUtils { /** * Private constructor to prevent instantiation of this utility class. * All methods are static and should be called directly on the class. */ private constructor(); /** * Converts an object to a JSON-serializable format with comprehensive type handling and circular reference protection. * * Handles special cases including: * - Date objects (converted to ISO strings) * - RegExp objects (converted to string representation) * - Error objects (converted to structured object with name, message, stack) * - Node.js-specific objects (Timeout, EventEmitter, etc. - converted to descriptive strings) * - Circular references (replaced with '[Circular Reference]' string) * - Functions and symbols (excluded from output) * * @param object - The object to convert to JSON-safe format * @returns A JSON-serializable version of the input object, or the original value for primitives * * @example * ```typescript * const complexObj = { * date: new Date(), * error: new Error('test'), * regex: /test/g, * func: () => {}, // Will be excluded * circular: null as any * }; * complexObj.circular = complexObj; // Create circular reference * * const safe = JsonUtils.objectToJson(complexObj); * // Result: { date: "2023-...", error: {...}, regex: "/test/g", circular: "[Circular Reference]" } * ``` */ static objectToJson(object: unknown): any; } //# sourceMappingURL=JsonUtils.d.ts.map