MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / readState

Function readState

src/utils/cacheStats.ts:81–90  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

79 * Read state file. Returns init defaults on any error (corrupt, missing, etc.).
80 */
81export async function readState(filePath: string): Promise<CacheStatsState> {
82 try {
83 const raw = await readFile(filePath, 'utf8')
84 const parsed: unknown = JSON.parse(raw)
85 if (isValidState(parsed)) return parsed
86 return { ...INIT_STATE }
87 } catch {
88 return { ...INIT_STATE }
89 }
90}
91
92/**
93 * Write state atomically: write to a tmp file then rename — safe against

Callers 2

initCacheStatsStateFunction · 0.85
cacheStats.test.tsFile · 0.85

Calls 2

readFileFunction · 0.85
isValidStateFunction · 0.85

Tested by

no test coverage detected