MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / streamOnEnd

Function streamOnEnd

source code/utils/readFileInRange.ts:308–344  ·  view source on GitHub ↗
(this: StreamState)

Source from the content-addressed store, hash-verified

306}
307
308function streamOnEnd(this: StreamState): void {
309 let line = this.partial
310 if (line.endsWith('\r')) {
311 line = line.slice(0, -1)
312 }
313 if (
314 this.currentLineIndex >= this.offset &&
315 this.currentLineIndex < this.endLine
316 ) {
317 if (this.truncateOnByteLimit && this.maxBytes !== undefined) {
318 const sep = this.selectedLines.length > 0 ? 1 : 0
319 const nextBytes = this.selectedBytes + sep + Buffer.byteLength(line)
320 if (nextBytes > this.maxBytes) {
321 this.truncatedByBytes = true
322 } else {
323 this.selectedLines.push(line)
324 }
325 } else {
326 this.selectedLines.push(line)
327 }
328 }
329 this.currentLineIndex++
330
331 const content = this.selectedLines.join('\n')
332 const truncated = this.truncatedByBytes
333 this.mtimeReady.then(mtimeMs => {
334 this.resolve({
335 content,
336 lineCount: this.selectedLines.length,
337 totalLines: this.currentLineIndex,
338 totalBytes: this.totalBytesRead,
339 readBytes: Buffer.byteLength(content, 'utf8'),
340 mtimeMs,
341 ...(truncated ? { truncatedByBytes: true } : {}),
342 })
343 })
344}
345
346function readFileInRangeStreaming(
347 filePath: string,

Callers

nothing calls this directly

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected