web-console-progress-bar
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

web-console-progress-bar

NPM Version

A progress bar for the browser console.

Install

npm install web-console-progress-bar

Usage

import { ConsoleProgressBar } from "web-console-progress-bar"

const progressBar = new ConsoleProgressBar(100)
progressBar.update(10)
//=> Progress: [██████░░░░░░░░░░░░] 10% ETA: XXs

or

const progressBar = new ConsoleProgressBar(100)

for (let i = 0; i <= 100; i++) {
  progressBar.update(i)
  // Simulate some delay
  await new Promise((resolve) => setTimeout(resolve, 100))
}

This will create a progress bar in the console that updates every 2 seconds (default updateInterval), and clears the console before each update (default clearConsole).

API

Constructor

constructor(total: number, updateInterval?: number, clearConsole?: boolean)

Creates a new instance of ConsoleProgressBar.

  • total (number): The total number of items to process.
  • updateInterval (number, optional): The interval (in milliseconds) at which to update the progress bar. Default is 2000.
  • clearConsole (boolean, optional): Indicates whether to clear the console before updating the progress bar. Default is true.

Method: update

update(currentValue: number): void

Updates the current value of the progress bar.

  • currentValue (number): The current value.

Package Sidebar

Install

npm i web-console-progress-bar

Weekly Downloads

0

Version

1.2.3

License

MIT

Unpacked Size

8.19 kB

Total Files

5

Last publish

Collaborators

  • spookyuser