yaprog
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

yaprog: Yet Another Progress Bar

What

A command line progress bar for NodeJS.

How

Quick Start

import { makeProgressBar } from 'yaprog';

const bar = makeProgressBar(`uploading [:bar] :current/:total :custom`, 100);

// set
bar.update(10, { custom: 'replacement text' });

// interrupt the bar and log some text
bar.interrupt(`Some log message here!`);

ProgressBarOptions interface

interface ProgressBarOptions {
  completeChar?: string; // defaults to '█'
  incompleteChar?: string; // defaults to '░'
  renderThrottle?: number; // defaults to 16ms (60fps)
  start?: number; // defaults to Date.now()
  stream?: NodeJS.WriteStream; // defaults to process.stderr
  total?: number; // defaults to 0
  width?: number; // defaults to 40
}

ProgressBar interface

interface ProgressBar {
  progress: number;
  total: number;
  tokens: ProgressBarTokens;
  clear(): void;
  log(message: string, tokens?: ProgressBarTokens): void;
  render(force?: boolean, tokens?: ProgressBarTokens): void;
  update(current: number, total?: number, tokens?: ProgressBarTokens): void;
  update(current: number, tokens: ProgressBarTokens): void;
}

ProgressBarTokens interface

interface ProgressBarTokens {
  [key: string]: any;
}

Why

This is based on progress, but simplifies the interface and fixes some bugs.

Readme

Keywords

Package Sidebar

Install

npm i yaprog

Weekly Downloads

0

Version

0.4.2

License

MIT

Unpacked Size

40 kB

Total Files

32

Last publish

Collaborators

  • gordonmleigh