MCPcopy
hub / github.com/vercel/chatbot / normalizeStreamData

Function normalizeStreamData

tests/routes/chat.test.ts:9–25  ·  view source on GitHub ↗
(lines: string[])

Source from the content-addressed store, hash-verified

7
8// Helper function to normalize stream data for comparison
9function normalizeStreamData(lines: string[]): string[] {
10 return lines.map((line) => {
11 if (line.startsWith('data: ')) {
12 try {
13 const data = JSON.parse(line.slice(6)); // Remove 'data: ' prefix
14 if (data.id) {
15 // Replace dynamic id with a static one for comparison
16 return `data: ${JSON.stringify({ ...data, id: 'STATIC_ID' })}`;
17 }
18 return line;
19 } catch {
20 return line; // Return as-is if it's not valid JSON
21 }
22 }
23 return line;
24 });
25}
26
27test.describe
28 .serial('/api/chat', () => {

Callers 1

chat.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…