MCPcopy Index your code
hub / github.com/anomalyco/opencode / approxBytes

Function approxBytes

packages/app/src/context/file/content-cache.ts:9–16  ·  view source on GitHub ↗
(content: FileContent)

Source from the content-addressed store, hash-verified

7let total = 0
8
9export function approxBytes(content: FileContent) {
10 const patchBytes =
11 content.patch?.hunks.reduce((sum, hunk) => {
12 return sum + hunk.lines.reduce((lineSum, line) => lineSum + line.length, 0)
13 }, 0) ?? 0
14
15 return (content.content.length + (content.diff?.length ?? 0) + patchBytes) * 2
16}
17
18function setBytes(path: string, nextBytes: number) {
19 const prev = lru.get(path)

Callers 2

loadFunction · 0.90
getFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected