cli-progress
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
string-width | 4.2.3 | 2.33 kB | MIT | prod |
cli-progress is a useful npm package offering an easy-to-use progress bar for command-line or terminal applications. It has several useful features such as a fully customizable output format using different placeholders, single and multi progress-bar modes, ETA calculation based on elapsed time, support for both TTY and NOTTY mode, asynchronous and synchronous task handling, and many more.
To use cli-progress in your JavaScript code, you first need to install it using either yarn or npm.
$ yarn add cli-progress
$ npm install cli-progress --save
After the installation, import the package into your JavaScript file and create a new instance of the progress bar. You can start, update, increment, set total value for, or stop the progress bar as needed. Here's a quick example:
const cliProgress = require('cli-progress');
// create a new progress bar instance and use shades_classic theme
const bar1 = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
// start the progress bar with a total value of 200 and start value of 0
bar1.start(200, 0);
// update progress
bar1.update(100);
// stop the progress bar
bar1.stop();
The constructor new cliProgress.SingleBar(options:object [, preset:object]);
is used to initialize a new progress bar. You can use the start, update, increment, and stop methods to control the behavior of the progress bar.
cli-progress documentation can be found right on the GitHub repository at https://github.com/npkgz/cli-progress.git. The readme file in the repository provides a detailed explanation of the package, along with several examples demonstrating various uses of the CLI-progress. Moreover, there is a specific section for events in the 'docs' directory for more detailed information and examples.