Progress

progress

Flexible ascii progress bar.

Install it: npm install progress

Example usage:

  • Create a ProgressBar.
  • Give it a format string.
  • Give the total, telling the progress bar when to stop!
  • Finally do tick() appropriately.
1
2
3
4
5
6
7
8
9
10
var ProgressBar = require('progress');

var bar = new ProgressBar(':bar', { total: 10 });
var timer = setInterval(function () {
  bar.tick();
  if (bar.complete) {
    console.log('\ncomplete\n');
    clearInterval(timer);
  }
}, 100);

Options

These are keys in the options object you can pass to the progress bar along with total as seen in the example above.

  • 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
  • complete completion character defaulting to "="
  • incomplete incomplete character defaulting to "-"
  • clear option to clear the bar on completion defaulting to false
  • callback optional function to call when the progress bar completes

Tokens

These are tokens you can use in the format of your progress bar.

  • :bar the progress bar itself
  • :current current tick number
  • :total total ticks
  • :elapsed time elapsed in seconds
  • :percent completion percentage
  • :eta estimated completion time in seconds

Do checkout their examples folder.

GIF FTW!

Thanks to TJ and rest of the maintainers for node-progress!

Suggest a module

Comments