Skip to main content

Abstract Class: ProgressBar

Constructors​

Constructor​

new ProgressBar(format, options?): ProgressBar

Initialize a ProgressBar with the given fmt string and options ortotal.

Options:

  • curr current completed index
  • total total number of ticks to complete
  • width the displayed width of the progress bar defaulting to total
  • stream the output stream defaulting to stderr
  • head head character defaulting to complete character
  • complete completion character defaulting to "="
  • incomplete incomplete character defaulting to "-"
  • renderThrottle minimum time between updates in milliseconds defaulting to 16
  • callback optional function to call when the progress bar completes
  • clear will clear the progress bar upon termination

Tokens:

  • :bar the progress bar itself
  • :current current tick number
  • :total total ticks
  • :elapsed time elapsed in seconds
  • :percent completion percentage
  • :eta eta in seconds
  • :rate rate of ticks per second

Parameters​

format​

string

options?​

any = {}

Returns​

ProgressBar

Properties​

total​

total: number = 0

Accessors​

currentAmount​

Set Signature​

set currentAmount(value): void

Parameters​
value​

number

Returns​

void

Methods​

interrupt()​

interrupt(message): void

"interrupt" the progress bar and write a message above it.

Parameters​

message​

string

Returns​

void


render()​

render(): void

Returns​

void


terminate()​

abstract terminate(): void

Returns​

void


tick()​

tick(delta): void

"tick" the progress bar with optional len and optional tokens.

Parameters​

delta​

number

Returns​

void


update()​

update(ratio): void

"update" the progress bar to represent an exact percentage. The ratio (between 0 and 1) specified will be multiplied by total and floored, representing the closest available "tick." For example, if a progress bar has a length of 3 and update(0.5) is called, the progress will be set to 1.

A ratio of 0.5 will attempt to set the progress to halfway.

Parameters​

ratio​

number

Returns​

void