Détail du package

ora-progress-bar

ZE0TRON609MIT1.2.1

A progress bar based on ora library

ora, progressbar, progress, bar

readme

Ora Progress Bar

A cli progress bar based on ora library.

NPM link

Usage

Create a ProgressBar(title,numberOfSteps,options?)

const ProgressBar = require("ora-progress-bar");

const progressBar = new ProgressBar("Current Progress", 100);

The options parameter is optional if you want to customize the ora spinner you can pass them see.

Increase the progress using progressBar.progress(progress=1)

progressBar.progress();

progressBar.progress(5);

Fail or Succeed

By default when the progressBar reaches its goal, it stops and succeeds. But you can force them to fail or succeed manually.

try {
  // do stuff
  progressBar.progress();
} catch (e) {
  progressBar.fail();
}
if (flag) {
  progressBar.succeed();
} else {
  progressBar.progress();
}

Update goal and current progress on the run

if (newWorkReceived) progressBar.updateGoal(progressBar.goal + newWork.length);
if (batchFailed) progressBar.updateProgress(0);

Note

Only one progress bar can be active at a time.

changelog

1.2.1 / 2020-04-17

  • Unnecessary files deleted from package.
  • ETA calculation algorithm changed to exponential moving average.

1.2.0 / 2020-04-16

  • ETA calculation added.
  • Percentage added.

1.1.0 / 2020-04-15

  • JSDoc added.
  • Some abstraction layers added.
  • Bugs fixed about :
    • Progress bar creation exceptions
    • Current progress
  • Update progress added.
  • Update goal added.