Recursively strip `cache_control` fields — marker movement is not content.
(value: unknown)
| 71 | |
| 72 | /** Recursively strip `cache_control` fields — marker movement is not content. */ |
| 73 | function 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 | |
| 86 | function hasCacheControl(block: unknown): boolean { |
| 87 | return !!block && typeof block === "object" && "cache_control" in (block as Json); |
no outgoing calls
no test coverage detected