Add JSDoc to splitAnsiCarryover function
This commit is contained in:
parent
a8eea4e694
commit
c09654c6c7
1 changed files with 16 additions and 2 deletions
|
|
@ -81,8 +81,22 @@ function broadcastSSE(event: SSEEvent): void {
|
|||
}
|
||||
}
|
||||
|
||||
// Detect and split any incomplete ANSI control sequence at the end of a chunk.
|
||||
// Returns [body, carry] where carry should be saved and prepended to the next chunk.
|
||||
/**
|
||||
* Detect and split any incomplete ANSI control sequence at the end of a chunk.
|
||||
*
|
||||
* ANSI sequences can span multiple network packets. This function identifies
|
||||
* incomplete sequences at the end of a chunk to prevent them from being
|
||||
* rendered as partial/broken control codes.
|
||||
*
|
||||
* @param chunk - Raw output string potentially containing ANSI sequences
|
||||
* @returns Tuple of [body, carry] where:
|
||||
* - body: Complete portion safe to render
|
||||
* - carry: Incomplete sequence to prepend to next chunk
|
||||
*
|
||||
* @example
|
||||
* const [body, carry] = splitAnsiCarryover("hello\x1b[31");
|
||||
* // body = "hello", carry = "\x1b[31"
|
||||
*/
|
||||
function splitAnsiCarryover(chunk: string): [string, string] {
|
||||
if (!chunk) return ["", ""];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue