perf: speed up memory batch polling
This commit is contained in:
17
src/terminal/progress-line.ts
Normal file
17
src/terminal/progress-line.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
let activeStream: NodeJS.WriteStream | null = null;
|
||||
|
||||
export function registerActiveProgressLine(stream: NodeJS.WriteStream): void {
|
||||
if (!stream.isTTY) return;
|
||||
activeStream = stream;
|
||||
}
|
||||
|
||||
export function clearActiveProgressLine(): void {
|
||||
if (!activeStream?.isTTY) return;
|
||||
activeStream.write("\r\x1b[2K");
|
||||
}
|
||||
|
||||
export function unregisterActiveProgressLine(stream?: NodeJS.WriteStream): void {
|
||||
if (!activeStream) return;
|
||||
if (stream && activeStream !== stream) return;
|
||||
activeStream = null;
|
||||
}
|
||||
Reference in New Issue
Block a user