MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / since

Method since

src/workspaces/replay-buffer.ts:57–79  ·  view source on GitHub ↗
(seq: number)

Source from the content-addressed store, hash-verified

55 }
56
57 since(seq: number): ReplaySlice {
58 const effectiveSeq = Math.max(seq, this.head);
59 const tailSeq = this.tailSeq;
60 if (effectiveSeq >= tailSeq) {
61 return { bytes: EMPTY, effectiveSeq, tailSeq };
62 }
63 const skipBytes = effectiveSeq - this.head;
64 const out: Buffer[] = [];
65 let remainingSkip = skipBytes;
66 for (const chunk of this.chunks) {
67 if (remainingSkip >= chunk.length) {
68 remainingSkip -= chunk.length;
69 continue;
70 }
71 if (remainingSkip > 0) {
72 out.push(chunk.subarray(remainingSkip));
73 remainingSkip = 0;
74 } else {
75 out.push(chunk);
76 }
77 }
78 return { bytes: Buffer.concat(out), effectiveSeq, tailSeq };
79 }
80
81 private evict(): void {
82 while (this.totalBytes > this.maxBytes) {

Callers 2

dumpReplayBufferMethod · 0.80
attachMethod · 0.80

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected