MCPcopy
hub / github.com/Effect-TS/effect / parse

Function parse

packages/cli/src/internal/files.ts:44–58  ·  view source on GitHub ↗
(
  path: string,
  content: string,
  format?: "json" | "yaml" | "ini" | "toml"
)

Source from the content-addressed store, hash-verified

42
43/** @internal */
44export const parse = (
45 path: string,
46 content: string,
47 format?: "json" | "yaml" | "ini" | "toml"
48): Effect.Effect<unknown, string> => {
49 const parser = fileParsers[format ?? path.split(".").pop() as string]
50 if (parser === undefined) {
51 return Effect.fail(`Unsupported file format: ${format}`)
52 }
53
54 return Effect.try({
55 try: () => parser(content),
56 catch: (e) => `Could not parse ${format} file (${path}): ${e}`
57 })
58}

Callers 1

attemptFunction · 0.70

Calls 3

parserFunction · 0.85
splitMethod · 0.80
failMethod · 0.65

Tested by

no test coverage detected