MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / transform

Function transform

sdk/src/impl/chatgpt-backend-fetch.ts:413–434  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

411
412 return new TransformStream<Uint8Array, Uint8Array>({
413 transform(chunk, controller) {
414 buffer += decoder.decode(chunk, { stream: true })
415
416 const lines = buffer.split('\n')
417 buffer = lines.pop() ?? ''
418
419 for (const line of lines) {
420 if (!line.startsWith('data: ')) continue
421
422 const jsonStr = line.slice(6).trim()
423 if (!jsonStr || jsonStr === '[DONE]') {
424 continue
425 }
426
427 try {
428 const parsed = JSON.parse(jsonStr) as Record<string, unknown>
429 processEvent(controller, parsed)
430 } catch {
431 // Skip unparseable lines
432 }
433 }
434 },
435
436 flush(controller) {
437 if (buffer.trim().startsWith('data: ')) {

Callers 1

transformJsonInStringFunction · 0.85

Calls 2

processEventFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected