MCPcopy Create free account
hub / github.com/microsoft/data-formulator / parseStreamLine

Function parseStreamLine

src/app/apiClient.ts:118–134  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

116 * Handles the current stream format: `{type: "...", data?: ..., error?: ...}`.
117 */
118export 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

Callers 2

apiClient.test.tsFile · 0.90
streamRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected