0.0.6 • Published 2 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:
max
the max value of the progressBarprogress
the default start progressformat
the 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
finished
value return if the bar progress is >= to the bar max