MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / readFileJson

Function readFileJson

packages/@contentlayer/utils/src/node/fs.ts:83–94  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

81 )
82
83const readFileJson = <T extends JsonValue = JsonValue>(
84 filePath: string,
85): T.Effect<OT.HasTracer, ReadFileError | FileNotFoundError | JsonParseError, T> =>
86 pipe(
87 readFile(filePath),
88 T.chain((str) =>
89 T.tryCatch(
90 () => JSON.parse(str) as T,
91 (error) => new JsonParseError({ str, error }),
92 ),
93 ),
94 )
95
96const readFileJsonIfExists = <T extends JsonValue = JsonValue>(
97 filePath: string,

Callers 1

readFileJsonIfExistsFunction · 0.70

Calls 1

readFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…