MCPcopy
hub / github.com/openclaw/clawsweeper / parseGhJsonLines

Function parseGhJsonLines

src/github-json.ts:13–27  ·  view source on GitHub ↗
(text: string, args: readonly string[])

Source from the content-addressed store, hash-verified

11}
12
13export function parseGhJsonLines<T>(text: string, args: readonly string[]): T[] {
14 if (!text) return [];
15 return text
16 .split("\n")
17 .filter(Boolean)
18 .map((line, index) => {
19 try {
20 return JSON.parse(line) as T;
21 } catch (error) {
22 throw new Error(
23 `Failed to parse JSON line ${index + 1} from ${summarizeGhArgs(args)}: ${formatParseError(error)}`,
24 );
25 }
26 });
27}
28
29function formatParseError(error: unknown): string {
30 return error instanceof Error ? error.message : String(error);

Callers 2

ghJsonLinesFunction · 0.90

Calls 2

summarizeGhArgsFunction · 0.85
formatParseErrorFunction · 0.85

Tested by

no test coverage detected