MCPcopy Index your code
hub / github.com/codeaashu/claude-code / resolveMetadataBuf

Function resolveMetadataBuf

src/utils/sessionStorage.ts:3130–3147  ·  view source on GitHub ↗
(
  carry: Buffer | null,
  chunkBuf: Buffer,
)

Source from the content-addressed store, hash-verified

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