bottom-bar

1.0.4 • Public • Published

bottom-bar.js

CLI status bar.

Table of Contents

  1. Documentation
    1. Installation
    2. Usage
    3. Methods
  2. Known issues
  3. News
  4. License

Goal

status-bar (based on inquirer inquirer) displays a status (progress) line below your output.

Documentation

Installation

npm:
npm install bottom-bar
yarn:
yarn add bottom-bar

Usage

const BottomBar = require('bottom-bar');

const bottomBar = BottomBar();
const max = 200;
for (let curr = 0; curr < max; curr += 10)
{
    bottomBar.update(curr, max);
    // Sleep - Here is your part of code
    await new Promise(resolve => {setTimeout(resolve, 1000)});
}

bottomBar.destroy();

Methods

const bottomBar = BottomBar(options);

Creates a new BottomBar instance

  • options (Object)
  • returns BottomBar

Options

  • barsize: (Number) A length of progress bar. Defaults: 40
  • barCompleteChar: (String) Character to use as "complete" indicator in the bar (default: "ਜ")
  • barIncompleteChar: (String) Character to use as "incomplete" indicator in the bar (default: "&#u2591;")
  • format: (String) progress bar output format @see format section

Bar Formatting

The progressbar can be customized by using the following build-in placeholders. They can be combined in any order.

  • {bar} - the progress bar, customizable by the options barsize, barCompleteChar and barIncompleteChar
  • {percentage} - the current progress in percent (0-100)
  • {total} - the end value
  • {value} - the current value set by last update() call

Custom values can be passed by update call:

const bottomBar = BottomBar({
    format: 'Progress |' + Colors.cyan('{bar}') + '| {percentage}% | {value}/{total} | {customValue}',
});
bottomBar.update(value, total, {
    customValue: 'test',
});

bottomBar.update(value, total, customValues)

Puts a progress bar to output

  • value (Number) - current value
  • total (Number) - max value
  • customValues (Object) - additional parameters in format

bottomBar.clear()

Removes bottom bar from output

bottomBar.log()

Prints a log and keeps a progress bar

bottomBar.destroy()

Destroys an instance of bottomBar and associated streams

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    9
    • latest

Version History

Package Sidebar

Install

npm i bottom-bar

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

5.78 kB

Total Files

6

Last publish

Collaborators

  • andreyh