MCPcopy Create free account
hub / github.com/Effect-TS/effect / readJsonFile

Function readJsonFile

packages/tools/docgen/src/Configuration.ts:155–168  ·  view source on GitHub ↗
(
  path: string
)

Source from the content-addressed store, hash-verified

153}
154
155const readJsonFile = (
156 path: string
157): Effect.Effect<unknown, never, FileSystem.FileSystem> =>
158 Effect.gen(function*() {
159 const fs = yield* FileSystem.FileSystem
160 const content = yield* Effect.orDie(fs.readFileString(path))
161 return yield* pipe(
162 Effect.try({
163 try: () => JSON.parse(content),
164 catch: (error) => `[FileSystem] Unable to read and parse JSON file from '${path}': ${String(error)}`
165 }),
166 Effect.orDie
167 )
168 })
169
170const validateJsonFile = <A, I>(
171 schema: Schema.Codec<A, I>,

Callers 1

validateJsonFileFunction · 0.85

Calls 3

pipeFunction · 0.50
StringInterface · 0.50
parseMethod · 0.45

Tested by

no test coverage detected