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

Function resolveMetadataBuf

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

Source from the content-addressed store, hash-verified

3222// null = carry spans whole chunk. Skips concat when carry provably isn't
3223// a metadata line (markers sit at byte 1 after `{`).
3224function resolveMetadataBuf(
3225 carry: Buffer | null,
3226 chunkBuf: Buffer,
3227): Buffer | null {
3228 if (carry === null || carry.length === 0) return chunkBuf
3229 if (carry.length < METADATA_PREFIX_BOUND) {
3230 return Buffer.concat([carry, chunkBuf])
3231 }
3232 if (carry[0] === 0x7b /* { */) {
3233 for (const m of METADATA_MARKER_BUFS) {
3234 if (carry.compare(m, 0, m.length, 1, 1 + m.length) === 0) {
3235 return Buffer.concat([carry, chunkBuf])
3236 }
3237 }
3238 }
3239 const firstNl = chunkBuf.indexOf(0x0a)
3240 return firstNl === -1 ? null : chunkBuf.subarray(firstNl + 1)
3241}
3242
3243/**
3244 * 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