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

Function parseJSONLString

source code/utils/json.ts:157–177  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

155}
156
157function parseJSONLString<T>(data: string): T[] {
158 const stripped = stripBOM(data)
159 const len = stripped.length
160 let start = 0
161
162 const results: T[] = []
163 while (start < len) {
164 let end = stripped.indexOf('\n', start)
165 if (end === -1) end = len
166
167 const line = stripped.substring(start, end).trim()
168 start = end + 1
169 if (!line) continue
170 try {
171 results.push(JSON.parse(line) as T)
172 } catch {
173 // Skip malformed lines
174 }
175 }
176 return results
177}
178
179/**
180 * Parses JSONL data from a string or Buffer, skipping malformed lines.

Callers 1

parseJSONLFunction · 0.85

Calls 1

stripBOMFunction · 0.90

Tested by

no test coverage detected