MCPcopy
hub / github.com/wavetermdev/waveterm / StreamToLines

Function StreamToLines

pkg/util/utilfn/streamtolines.go:61–74  ·  view source on GitHub ↗
(input io.Reader, lineFn func([]byte), readCallback func())

Source from the content-addressed store, hash-verified

59}
60
61func StreamToLines(input io.Reader, lineFn func([]byte), readCallback func()) error {
62 var lineBuf lineBuf
63 readBuf := make([]byte, 64*1024)
64 for {
65 n, err := input.Read(readBuf)
66 streamToLines_processBuf(&lineBuf, readBuf[:n], lineFn)
67 if err != nil {
68 return err
69 }
70 if readCallback != nil {
71 readCallback()
72 }
73 }
74}
75
76// starts a goroutine to drive the channel
77// line output does not include the trailing newline

Callers 2

AdaptStreamToMsgChFunction · 0.92
StreamToLinesChanFunction · 0.70

Calls 2

streamToLines_processBufFunction · 0.70
ReadMethod · 0.45

Tested by

no test coverage detected