(seq: number)
| 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) { |
no test coverage detected