1.1.3 • Published 6 years ago
@node_js/progress v1.1.3
ProgressBar
ProgressBar in cmd or powershell
Install
$ npm i @node_js/progressUseage
const ProgressBar = require('@node_js/progress');
const title = 'downloading:';
const total = 100;
const progress = new ProgressBar({
title,
total
});
let completed = 0;
function downloading() {
if (completed <= total) {
progress.render(completed++);
setTimeout(function (){
downloading();
}, 100)
}
}
downloading();More examples in the examples folder.
options
constructor
titleoptional, Progress bar title- default: ''
totaloptional, total number of ticks to complete- Can also be set within the render method
widthoptional, the displayed width of the progress- default: 50
completeoptional, completion character- default: colors.bgGreen(' '), can use any string
incompleteoptional, incomplete character- default: colors.bgWhite(' '), can use any string
intervaloptional, minimum time between updates in milliseconds, default: 16displayoptional, What is displayed and display order- default: ':title :percent :bar :time :completed/:total'
clearoptional, clear the bar on completion- default: false
render
completedcompleted valuetotaloptional, total number of ticks to complete, Can also be set in the constructor
console
messageinterrupt the progress bar and write a message above it
end
- end a progress bar
types
/**
* constructor
*
* @param {String} [title] Progress bar title, default: ''
* @param {Number} [total] total number of ticks to complete, Can also be set within the render method
* @param {Number} [width] the displayed width of the progress, default: 50
* @param {String} [complete] completion character, default: colors.bgGreen(' '), can use any string
* @param {String} [incomplete] incomplete character, default: colors.bgWhite(' '), can use any string
* @param {Boolean} [clear] clear the bar on completion, default: false
* @param {Number} [interval] minimum time between updates in milliseconds, default: 16
* @param {String} [display] What is displayed and display order, default: ':title :percent :bar :time :completed/:total'
*/
/**
* render: render the progress bar
*
* @param {Number} completed Completed value
* @param {Number} [total] total number of ticks to complete, Can also be set in the constructor
*/
/**
* console: interrupt the progress bar and write a message above it
*
* @param {string | number} message The message to write
*/
/**
* end: end a progress bar.
*
* @api public
*/