MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / processLine

Function processLine

src/client/stream.ts:15–47  ·  view source on GitHub ↗
(rawLine: string)

Source from the content-addressed store, hash-verified

13 let event: Partial<ServerSentEvent> = {};
14
15 const processLine = (rawLine: string): ServerSentEvent | undefined => {
16 const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
17
18 if (line === '') {
19 const completed = event.data !== undefined
20 ? { data: event.data, event: event.event, id: event.id }
21 : undefined;
22 event = {};
23 return completed;
24 }
25
26 if (line.startsWith(':')) return undefined;
27
28 const colonIndex = line.indexOf(':');
29 if (colonIndex === -1) return undefined;
30
31 const field = line.slice(0, colonIndex);
32 const value = line.slice(colonIndex + 1).trimStart();
33
34 switch (field) {
35 case 'data':
36 event.data = event.data !== undefined ? `${event.data}\n${value}` : value;
37 break;
38 case 'event':
39 event.event = value;
40 break;
41 case 'id':
42 event.id = value;
43 break;
44 }
45
46 return undefined;
47 };
48
49 try {
50 while (true) {

Callers 1

parseSSEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected