MCPcopy
hub / github.com/claude-code-best/claude-code / parseJSONLString

Function parseJSONLString

src/utils/json.ts:155–175  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

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

Callers 1

parseJSONLFunction · 0.85

Calls 2

stripBOMFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected