MCPcopy Index your code
hub / github.com/codeaashu/claude-code / isJsonLine

Function isJsonLine

src/utils/streamJsonStdoutGuard.ts:14–26  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

12let originalWrite: typeof process.stdout.write | null = null
13
14function isJsonLine(line: string): boolean {
15 // Empty lines are tolerated in NDJSON streams — treat them as valid so a
16 // trailing newline or a blank separator doesn't trip the guard.
17 if (line.length === 0) {
18 return true
19 }
20 try {
21 JSON.parse(line)
22 return true
23 } catch {
24 return false
25 }
26}
27
28/**
29 * Install a runtime guard on process.stdout.write for --output-format=stream-json.

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected