1.2.1 • Published 3 years ago

@zhangfuxing/progress v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ProgressBar

ProgressBar output in terminal written in nodejs

Multi-line progress bar output in terminal written in nodejs

https://github.com/fuxingZhang/multiProgressBar

Install

$ npm i @zhangfuxing/progress

Useage

const ProgressBar = require('@zhangfuxing/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

  • title optional, Progress bar title
    • default: ''
  • total optional, total number of ticks to complete
    • Can also be set within the render method
  • width optional, the displayed width of the progress
    • default: 50
  • complete optional, completion character
    • default: colors.bgGreen(' '), can use any string
  • incomplete optional, incomplete character
    • default: colors.bgWhite(' '), can use any string
  • interval optional, minimum time between updates in milliseconds, default: 16
  • display optional, What is displayed and display order
    • default: ':title :percent :bar :time :completed/:total'
  • clear optional, clear the bar on completion
    • default: false

render

  • completed completed value
  • total optional, total number of ticks to complete, Can also be set in the constructor

console

  • message interrupt 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
 */
1.2.1

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago