MCPcopy Create free account
hub / github.com/arktypeio/arktype / read

Method read

ark/aot/cache.ts:224–235  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

222 // one cut short or changed since it was written reads as missing, and is
223 // written again
224 private read(name: string): unknown {
225 let text: string
226 try {
227 text = readFileSync(join(this.dir, `${name}.json`), "utf8")
228 } catch {
229 return
230 }
231 const start = text.indexOf("\n") + 1
232 const body = text.slice(start)
233 if (start && text.slice(0, start - 1) === hashOf(body))
234 return JSON.parse(body)
235 }
236
237 // with its hash, and renamed into place once written, so a concurrent build
238 // reads all of it or none, and the last of two writing it wins. Its temp

Callers 2

getMethod · 0.95
snapshotMethod · 0.95

Calls 3

joinFunction · 0.85
hashOfFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected