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

Function captureSnap

src/utils/sessionStoragePortable.ts:662–685  ·  view source on GitHub ↗
(
  s: LoadState,
  buf: Buffer,
  chunk: Buffer,
  lastSnapStart: number,
  lastSnapEnd: number,
)

Source from the content-addressed store, hash-verified

660
661// In-buf snap wins over straddle (later in file). carryBuf still valid here.
662function captureSnap(
663 s: LoadState,
664 buf: Buffer,
665 chunk: Buffer,
666 lastSnapStart: number,
667 lastSnapEnd: number,
668): void {
669 if (lastSnapStart !== -1) {
670 s.lastSnapLen = lastSnapEnd - lastSnapStart
671 if (s.lastSnapBuf === undefined || s.lastSnapLen > s.lastSnapBuf.length) {
672 s.lastSnapBuf = Buffer.allocUnsafe(s.lastSnapLen)
673 }
674 buf.copy(s.lastSnapBuf, 0, lastSnapStart, lastSnapEnd)
675 s.lastSnapSrc = s.lastSnapBuf
676 } else if (s.straddleSnapCarryLen > 0) {
677 s.lastSnapLen = s.straddleSnapCarryLen + s.straddleSnapTailEnd
678 if (s.lastSnapBuf === undefined || s.lastSnapLen > s.lastSnapBuf.length) {
679 s.lastSnapBuf = Buffer.allocUnsafe(s.lastSnapLen)
680 }
681 s.carryBuf!.copy(s.lastSnapBuf, 0, 0, s.straddleSnapCarryLen)
682 chunk.copy(s.lastSnapBuf, s.straddleSnapCarryLen, 0, s.straddleSnapTailEnd)
683 s.lastSnapSrc = s.lastSnapBuf
684 }
685}
686
687function captureCarry(s: LoadState, buf: Buffer, trailStart: number): void {
688 s.carryLen = buf.length - trailStart

Callers 1

readTranscriptForLoadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected