MCPcopy
hub / github.com/garrytan/gstack / readJsonl

Function readJsonl

lib/jsonl-store.ts:77–96  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

75 * (forward-compatible: a schema bump on the writer doesn't break older readers).
76 */
77export function readJsonl<T = unknown>(path: string): T[] {
78 if (!existsSync(path)) return [];
79 let raw: string;
80 try {
81 raw = readFileSync(path, "utf-8");
82 } catch {
83 return [];
84 }
85 const out: T[] = [];
86 for (const line of raw.split("\n")) {
87 const trimmed = line.trim();
88 if (!trimmed) continue;
89 try {
90 out.push(JSON.parse(trimmed) as T);
91 } catch {
92 // Malformed line (partial tail / corruption) — skip, keep reading.
93 }
94 }
95 return out;
96}

Callers 2

readEventsFunction · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected