0.0.6 • Published 3 years ago
@mateoox600/m-console v0.0.6
MConsole
Npm package for console utilities.
Features
- Utility functions
- Progress bar
Installation
npm install @mateoox600/m-console- Typescript is supported and types comes with the installation
Usage
const { ProgressBar } = require('@mateoox600/m-console');
const progressBar = new ProgressBar(120, 10, '[{progressBar}] {progress}/{max}');
progressBar.start();
const interval = setInterval(() => {
progressBar.update(progressBar.getProgress() + 1);
if(progressBar.finished) {
progressBar.stop();
clearInterval(interval);
console.log('finished');
}
}, 10);Docs
clear()
- clear the console
ProgressBar
- Takes three args:
maxthe max value of the progressBarprogressthe default start progressformatthe format of the bar in the console
- You need to
.start()the bar before being able to use it - The bar automaticly stops when reaching the bar max
- An automatic redraw is done when you update the bar
getProgress()andgetMax()can be used to get the progress and max value of the bar- The
finishedvalue return if the bar progress is >= to the bar max