MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / resolveMetadataBuf

Function resolveMetadataBuf

source code/utils/sessionStorage.ts:3132–3149  ·  view source on GitHub ↗
(
  carry: Buffer | null,
  chunkBuf: Buffer,
)

Source from the content-addressed store, hash-verified

3130// null = carry spans whole chunk. Skips concat when carry provably isn't
3131// a metadata line (markers sit at byte 1 after `{`).
3132function resolveMetadataBuf(
3133 carry: Buffer | null,
3134 chunkBuf: Buffer,
3135): Buffer | null {
3136 if (carry === null || carry.length === 0) return chunkBuf
3137 if (carry.length < METADATA_PREFIX_BOUND) {
3138 return Buffer.concat([carry, chunkBuf])
3139 }
3140 if (carry[0] === 0x7b /* { */) {
3141 for (const m of METADATA_MARKER_BUFS) {
3142 if (carry.compare(m, 0, m.length, 1, 1 + m.length) === 0) {
3143 return Buffer.concat([carry, chunkBuf])
3144 }
3145 }
3146 }
3147 const firstNl = chunkBuf.indexOf(0x0a)
3148 return firstNl === -1 ? null : chunkBuf.subarray(firstNl + 1)
3149}
3150
3151/**
3152 * Lightweight forward scan of [0, endOffset) collecting only metadata-entry lines.

Callers 1

scanPreBoundaryMetadataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected