MCPcopy
hub / github.com/TanStack/ai / parseSse

Function parseSse

testing/e2e/tests/mcp-apps.spec.ts:36–51  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

34}
35
36function parseSse(body: string): Array<StreamEvent> {
37 const events: Array<StreamEvent> = []
38 for (const line of body.split('\n')) {
39 const trimmed = line.trim()
40 if (!trimmed.startsWith('data:')) continue
41 const json = trimmed.slice('data:'.length).trim()
42 if (!json) continue
43 try {
44 const parsed: unknown = JSON.parse(json)
45 if (isStreamEvent(parsed)) events.push(parsed)
46 } catch {
47 // Ignore non-JSON keepalive lines.
48 }
49 }
50 return events
51}
52
53function isStreamEvent(value: unknown): value is StreamEvent {
54 return (

Callers 1

mcp-apps.spec.tsFile · 0.70

Calls 3

isStreamEventFunction · 0.85
parseMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected