ongoing
v1.0.2
Published
A simple ascii progress bar renderer.
Downloads
10
Readme
Ongoing
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.
Installation
npm i ongoing
Example
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' }));
Features
- Custom tokens
- Update the bar to a specific value
- Tick the bar based on a delta
Default tokens
:current
: Displays the current value:total
: Displays the total value:percent
: Displays the current percentage:bar
: Displays the bar (required)
Options
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
Default values
const bar = new ProgressBar(':bar', {
total: 100,
width: 30,
completedChar: '=',
incompletedChar: '-',
headChar: '=',
});