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

Function cachedAnswerOf

ark/aot/driver.ts:838–852  ·  view source on GitHub ↗
(
	tracked: TrackedPrecompiler,
	cache: AnswerCache,
	key: string,
	// given the snapshot it names, which a scan reads again once it can't be reproduced
	onSnapshot?: (snapshot: string) => void
)

Source from the content-addressed store, hash-verified

836
837// an answer stored for what a key names whose snapshot still holds
838const cachedAnswerOf = (
839 tracked: TrackedPrecompiler,
840 cache: AnswerCache,
841 key: string,
842 // given the snapshot it names, which a scan reads again once it can't be reproduced
843 onSnapshot?: (snapshot: string) => void
844): unknown =>
845 cache.get(key, snapshot => {
846 onSnapshot?.(snapshot)
847 return (tracked.holds ??= createSnapshotCheck(
848 cache,
849 tracked.host,
850 tracked.resolveInBundler
851 ))(snapshot, tracked.given)
852 })
853
854// an answer outlives the build where nothing but what it read and resolved
855// decided it

Callers 2

answerFunction · 0.85
precompileFunction · 0.85

Calls 2

createSnapshotCheckFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected