GHHG10/CodeServer / opencode /packages /tui /src /util /collapse-tool-output.ts
GHHG10's picture
download
raw
595 Bytes
export function collapseToolOutput(output: string, maxLines: number, maxChars: number) {
const lines = output.split("\n")
if (lines.length <= maxLines && Array.from(output).length <= maxChars) {
return { output, overflow: false }
}
const preview = lines.slice(0, maxLines).join("\n")
if (Array.from(preview).length > maxChars) {
return {
output:
Array.from(preview)
.slice(0, Math.max(0, maxChars - 1))
.join("") + "…",
overflow: true,
}
}
return { output: [...lines.slice(0, maxLines), "…"].join("\n"), overflow: true }
}

Xet Storage Details

Size:
595 Bytes
·
Xet hash:
a5d28e91b6aec44f1139859135078291992918c5325ffdfb17a3bf111b50a68e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.