Progress
The Progress component creates animated progress bars in the terminal with spinner indicators, buffered progress support, rainbow animation, configurable symbols and colors, and multi-bar rendering. It extends EventEmitter for type-safe event handling and supports completion, cancellation, and error states. External console.log calls are automatically printed above the progress block without disrupting the display.

Constructor
new Progress(title: string,total?: number,options?: ProgressOptions,)
Parameters
title: The title displayed alongside the progress bar.total: The total value representing 100% completion. Defaults to100.options: An optionalProgressOptionsobject to configure labels and bar appearance (length, symbols, animation, and colors).
Methods
init(): Initializes the progress bar, registers it for multi-bar rendering, and starts the spinner.update(current, buffer?, options?): Updates the progress value and optional buffer. You can also passProgressUpdateOptionsto change the bar's message, labels, symbols, or colors mid-flight. Automatically completes whencurrentreachestotal.cancel(): Cancels the progress bar and emits the"cancel"event.error(...args: any[]): Sets the error state and emits the"error"event with the provided arguments.getIsExited(): Returnstrueif the progress bar has been cancelled or errored.
Events
"update": Emitted on each update. Passes(current: number, percentage: number)."complete": Emitted when progress reaches total. Passes(total: number)."cancel": Emitted when progress is cancelled."error": Emitted on error with the error arguments.
Features
- Multi-bar rendering: Multiple progress bars render together and finish as a group.
- Rainbow animation: Set
bar.animationto{ type: "rainbow" }for a scrolling parallax rainbow effect, or{ type: "rainbow-smooth" }for a full-spectrum 8-bit gradient. Control speed and wave size with the optionalspeedandsizefields. - Custom symbols: Configure
loadedSymbol,bufferedSymbol, andemptySymbolto change the bar characters. - State colors: Customize colors for loaded, buffered, empty, completed, cancelled, and errored states via
bar.color. - Full-width mode: Set
bar.lengthto"full-width"to fill the terminal width. - Safe stdout interception: External
console.logcalls are printed above the progress block without duplication.
Usage
import { Progress } from "ts-better-console";
const bar = new Progress("Downloading", 100);
bar.init();
let i = 0;
const timer = setInterval(() => {i += 10;}, 200);
bar.update(i);
if (i >= 100) clearInterval(timer);
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!