MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseJSONLBuffer

Function parseJSONLBuffer

source code/utils/json.ts:131–155  ·  view source on GitHub ↗
(buf: Buffer)

Source from the content-addressed store, hash-verified

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

Callers 1

parseJSONLFunction · 0.85

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected