Socket
Book a DemoInstallSign in
Socket

@open-tech-world/cli-progress-bar

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-tech-world/cli-progress-bar

Node.js CLI progress bar.

latest
Source
npmnpm
Version
2.0.2
Version published
Maintainers
1
Created
Source

@open-tech-world/cli-progress-bar

Build CodeFactor npm (scoped)

Node.js CLI progress bar.

Internally it uses @open-tech-world/es-cli-styles for terminal colors. Refer it for supported colors.

Installation

Using npm

$ npm install @open-tech-world/cli-progress-bar

Using Yarn

$ yarn add @open-tech-world/cli-progress-bar

Usage

import { ProgressBar } from '@open-tech-world/cli-progress-bar';

const pBar = new ProgressBar({ prefix: 'Downloading' });
pBar.run({ value: 0, total: 100 });
pBar.run({ value: 50, total: 100 });
pBar.run({ value: 100, total: 100, prefix: 'Download Completed!' });

API

new ProgressBar(options?: Partial<IOptions>)

It creates a new instance of the ProgressBar.

options:

NameTypeDefaultDescription
streamNodeJS.WriteStreamprocess.stderrThe stream to use.
widthnumber30The size of the progress bar.
prefixstring''The string to be prefixed progress bar.
suffixstring''The string to be suffixed progress bar.
colorstring'green'The color to render the progress bar. Refer the supported color names here.
autoClearbooleanfalseIf true, then it auto clears the progress bar when it reaches 100%.

Instance methods:

run(options: IRunOptions): void

Runs the current progress bar instance with the given values & options.

options:

NameTypeDefaultRequiredDescription
valuenumberNaNYesThe current value of the progress bar.
totalnumberNaNYesThe total value for the progress bar.
prefixstring''NoThe string to be prefixed progress bar.
suffixstring''NoThe string to be suffixed progress bar.
colorstring'green'NoThe color to render the progress bar. Refer the supported color names here.

stop(clear = false): void

Stops the current progress bar instance with the current state and optionally clears the progress bar.

pBar.stop(); // It just stops the progress bar.

pBar.stop(true); // It stops & removes the progress bar.

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).

Keywords

node

FAQs

Package last updated on 17 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts