MCPcopy Create free account
hub / github.com/cortexkit/magic-context / stripCacheControl

Function stripCacheControl

packages/e2e-tests/src/cache-analysis.ts:73–84  ·  view source on GitHub ↗

Recursively strip `cache_control` fields — marker movement is not content.

(value: unknown)

Source from the content-addressed store, hash-verified

71
72/** Recursively strip `cache_control` fields — marker movement is not content. */
73function stripCacheControl(value: unknown): unknown {
74 if (Array.isArray(value)) return value.map(stripCacheControl);
75 if (value && typeof value === "object") {
76 const out: Json = {};
77 for (const [k, v] of Object.entries(value as Json)) {
78 if (k === "cache_control") continue;
79 out[k] = stripCacheControl(v);
80 }
81 return out;
82 }
83 return value;
84}
85
86function hasCacheControl(block: unknown): boolean {
87 return !!block && typeof block === "object" && "cache_control" in (block as Json);

Callers 3

blockTextFunction · 0.70
buildSegmentsFunction · 0.70
rawSegmentTextFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected