@jawis/stdio-filter
Version:
Filter the stdio from console applications.
16 lines (15 loc) • 702 B
TypeScript
/**
* Interpret stdio with ansi codes into lines.
*
* - onStdio callback is called with individual lines, making it easy to handle the stdio stream.
* - newlines are not included in the lines given to onStdio.
* - ANSI codes are interpreted, so only styling is emitted in the lines.
* - ANSI codes can result in updates to lines. In that case the full line is emitted again.
* - Carriage return is filtered out, because it has special meaning in the console.
* - Lines are zero index'ed.
*
* todo
* drop lines, when buffer becomes too big.
*
*/
export declare const makeStdioInterpreter: (onLine: (lineNumber: number, line: string, buffer: string[]) => void) => (str: string) => void;