MCPcopy Create free account
hub / github.com/cortexkit/magic-context / parseRoot

Function parseRoot

packages/dashboard/src/lib/jsonc.ts:11–23  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

9}
10
11function parseRoot(text: string): Record<string, unknown> {
12 const source = text.trim() === "" ? "{}\n" : text;
13 let parsed: unknown;
14 try {
15 parsed = parse(source);
16 } catch (error) {
17 throw new Error(`Config JSONC parse failed: ${jsoncErrorMessage(error)}`);
18 }
19 if (!isRecord(parsed)) {
20 throw new Error("Config JSONC root must be an object");
21 }
22 return parsed;
23}
24
25/** Parse JSONC into an object. Throws on malformed JSONC instead of returning a destructive fallback. */
26export function parseJsonc(text: string): Record<string, unknown> {

Callers 3

parseJsoncFunction · 0.85
patchDreamerTasksJsoncFunction · 0.85
removeDreamerBlockJsoncFunction · 0.85

Calls 3

jsoncErrorMessageFunction · 0.85
isRecordFunction · 0.70
parseFunction · 0.50

Tested by

no test coverage detected