@ngmikeng/node-console-rateprogressbar
v1.0.0
Published
A simple function for showing a progress bar in node console.
Downloads
7
Maintainers
Readme
node-console-rateprogressbar
A simple function for showing a progress bar in node console.
Setup
$ npm install @ngmikeng/node-console-rateprogressbar --save
Example
const { progressBar } = require('@ngmikeng/node-console-rateprogressbar');
const total = 100;
let currentProgress = 0;
const inter = setInterval(() => {
currentProgress++;
const curRate = currentProgress / total;
if (currentProgress <= total) {
const opts = { label: 'Loading: ', symbol: '#'};
progressBar(curRate, opts);
} else {
clearInterval(inter);
console.log('\n');
}
}, 100);
The console will show:
Loading: [##################################################] | 100.00%
Options
- label (
string
): Show label on the left of progress bar, leavenull
orundefined
for hiding. - symbol (
string
): Define a symbol show on progress bar, default is=
. - showPercentageProgress (
boolean
): Show or hide percentage number, defaulttrue
.
License
MIT