A simple ascii progress bar renderer. It doesn't take care of printing the progress bar to the terminal, so that has to be done using other tools.
npm i ongoing
import { ProgressBar } from 'ongoing';
const bar = new ProgressBar(':message :bar :percent');
console.log(bar.update(0.2, { message: 'Hello' }));
console.log(bar.tick(1, { message: 'World' }));
- Custom tokens
- Update the bar to a specific value
- Tick the bar based on a delta
:current
: Displays the current value:total
: Displays the total value:percent
: Displays the current percentage:bar
: Displays the bar (required)
A second argument can be passed when instantiating the bar. The following options are supported:
total
: Indicates the maximum value of the progress barwidth
: Indicates the width in characters of the progress barcompletedChar
: Indicates the character to use to darw the completed sectionincompletedChar
: Indicates the character to use to draw the incompleted sectionheadChar
: Indicates a character to draw as the head of the completed section
const bar = new ProgressBar(':bar', {
total: 100,
width: 30,
completedChar: '=',
incompletedChar: '-',
headChar: '=',
});