Skip to content

sickagents/progbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

progbar

A lightweight, customizable progress bar library for terminal applications with zero dependencies.

Features

  • 🚀 Zero dependencies
  • 🎨 Customizable colors and styles
  • 📊 Multiple progress bar formats
  • ⚡ High performance
  • 🔧 Simple API
  • 📦 Tiny footprint (~5KB)

Installation

npm install progbar

Quick Start

const ProgressBar = require('progbar');

const bar = new ProgressBar({
  total: 100,
  width: 40,
  format: '[{bar}] {percentage}% | ETA: {eta}s'
});

// Update progress
for (let i = 0; i <= 100; i++) {
  bar.update(i);
}

API

Constructor Options

  • total (number): Total number of steps
  • width (number): Width of the progress bar (default: 40)
  • format (string): Format string with tokens
  • complete (string): Character for completed portion (default: '█')
  • incomplete (string): Character for incomplete portion (default: '░')
  • clear (boolean): Clear bar on completion (default: false)

Format Tokens

  • {bar} - The progress bar
  • {percentage} - Completion percentage
  • {current} - Current value
  • {total} - Total value
  • {eta} - Estimated time remaining
  • {elapsed} - Elapsed time

Methods

  • update(current) - Update progress to current value
  • tick(amount) - Increment progress by amount (default: 1)
  • complete() - Mark as complete
  • stop() - Stop and clear the bar

Examples

Basic Progress Bar

const bar = new ProgressBar({ total: 100 });
bar.update(50); // 50% complete

Custom Format

const bar = new ProgressBar({
  total: 100,
  format: 'Progress: [{bar}] {current}/{total} ({percentage}%)'
});

Custom Characters

const bar = new ProgressBar({
  total: 100,
  complete: '=',
  incomplete: '-',
  format: '[{bar}] {percentage}%'
});

With Colors (using ANSI codes)

const bar = new ProgressBar({
  total: 100,
  complete: '\x1b[32m█\x1b[0m',  // Green
  incomplete: '\x1b[90m░\x1b[0m', // Gray
  format: '[{bar}] {percentage}%'
});

License

MIT

About

Lightweight, customizable progress bar library for terminal applications with zero dependencies

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors