/** * Union type representing the standard output streams. */ type Stream = "stdout" | "stderr"; /** * Callback function to handle intercepted console output. * * @param stream - The stream the output is intended for ('stdout' or 'stderr'). * @param args - The raw arguments passed to the console method. */ type Callback = (stream: Stream, args: unknown[]) => void; /** * Patches global console methods to intercept output and redirect it to a callback. * * This function wraps standard console methods (like `console.log`, `console.error`, etc.) * so that they call the provided callback instead of writing directly to the stream. * It passes raw arguments to the callback, allowing the caller to handle formatting. * * @param callback - The function to call with the intercepted output. * @returns A function that restores the original console methods when called. * * @example * ```ts * const restore = patchConsole((stream, args) => { * console.log(`[${stream}] ${args.join(" ")}`); * }); * * console.log("Hello", "World"); // Output: [stdout] Hello World * * restore(); // Console is back to normal * ``` */ export declare const patchConsole: (callback: Callback) => (() => void); export {};