Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spookyuser/web-console-progress-bar
A progress bar for the browser console.
https://github.com/spookyuser/web-console-progress-bar
progress-bar progress-bar-component progress-bars
Last synced: 18 days ago
JSON representation
A progress bar for the browser console.
- Host: GitHub
- URL: https://github.com/spookyuser/web-console-progress-bar
- Owner: spookyuser
- License: mit
- Created: 2023-12-27T08:04:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-05T10:10:12.000Z (12 months ago)
- Last Synced: 2024-12-15T22:44:09.385Z (19 days ago)
- Topics: progress-bar, progress-bar-component, progress-bars
- Language: TypeScript
- Homepage:
- Size: 84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# web-console-progress-bar
[![NPM Version](https://img.shields.io/npm/v/web-console-progress-bar.svg)](https://www.npmjs.com/package/web-console-progress-bar)
> A progress bar for the browser console.
## Install
```sh
npm install web-console-progress-bar
```## Usage
```typescript
import { ConsoleProgressBar } from "web-console-progress-bar"const progressBar = new ConsoleProgressBar(100)
progressBar.update(10)
//=> Progress: [██████░░░░░░░░░░░░] 10% ETA: XXs
```or
```typescript
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
```typescript
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
```typescript
update(currentValue: number): void
```Updates the current value of the progress bar.
- `currentValue` (number): The current value.