1.2.3 • Published 4 months ago

web-console-progress-bar v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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.
1.2.3

4 months ago

1.2.0

4 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.0.4

4 months ago

0.0.1

4 months ago

0.0.0

4 months ago

1.0.0

4 months ago