(line: string)
| 116 | * Handles the current stream format: `{type: "...", data?: ..., error?: ...}`. |
| 117 | */ |
| 118 | export function parseStreamLine<T = any>(line: string): StreamEvent<T> | null { |
| 119 | const trimmed = line.trim(); |
| 120 | if (!trimmed) return null; |
| 121 | |
| 122 | let parsed: any; |
| 123 | try { |
| 124 | parsed = JSON.parse(trimmed); |
| 125 | } catch { |
| 126 | return null; |
| 127 | } |
| 128 | |
| 129 | if (parsed.type) { |
| 130 | return parsed as StreamEvent<T>; |
| 131 | } |
| 132 | |
| 133 | return null; |
| 134 | } |
| 135 | |
| 136 | // ====== High-level request functions ======================================= |
| 137 |
no outgoing calls
no test coverage detected