MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseJSONLBuffer

Function parseJSONLBuffer

src/utils/json.ts:129–153  ·  view source on GitHub ↗
(buf: Buffer)

Source from the content-addressed store, hash-verified

127}
128
129function parseJSONLBuffer<T>(buf: Buffer): T[] {
130 const bufLen = buf.length
131 let start = 0
132
133 // Strip UTF-8 BOM (EF BB BF)
134 if (buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf) {
135 start = 3
136 }
137
138 const results: T[] = []
139 while (start < bufLen) {
140 let end = buf.indexOf(0x0a, start)
141 if (end === -1) end = bufLen
142
143 const line = buf.toString('utf8', start, end).trim()
144 start = end + 1
145 if (!line) continue
146 try {
147 results.push(JSON.parse(line) as T)
148 } catch {
149 // Skip malformed lines
150 }
151 }
152 return results
153}
154
155function parseJSONLString<T>(data: string): T[] {
156 const stripped = stripBOM(data)

Callers 1

parseJSONLFunction · 0.85

Calls 3

toStringMethod · 0.65
pushMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected