MCPcopy Create free account
hub / github.com/devnomad-byte/EvolveHub / parseSseBlock

Function parseSseBlock

frontend/src/api/chat.ts:186–199  ·  view source on GitHub ↗

* 解析 SSE 数据块

(block: string)

Source from the content-addressed store, hash-verified

184 * 解析 SSE 数据块
185 */
186function parseSseBlock(block: string): ChatStreamEvent | null {
187 const dataLines = block
188 .split('\n')
189 .filter(line => line.startsWith('data:'))
190 .map(line => line.slice(5).trim())
191 if (!dataLines.length) {
192 return null
193 }
194 const payload = dataLines.join('\n')
195 if (!payload) {
196 return null
197 }
198 return JSON.parse(payload) as ChatStreamEvent
199}

Callers 1

sendMessageFunction · 0.85

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected