All Projects → deno-library → progress

deno-library / progress

Licence: MIT license
ProgressBar in terminal for deno

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to progress

aqua
A minimal and fast 🏃 web framework for Deno
Stars: ✭ 219 (+461.54%)
Mutual labels:  deno
logrocket deno api
A functional CRUD-like API with Deno and Postgres
Stars: ✭ 23 (-41.03%)
Mutual labels:  deno
deno install
Deno 安装器(国内加速)
Stars: ✭ 58 (+48.72%)
Mutual labels:  deno
deno-csv
Streaming API for reading and writing CSV for https://deno.land/
Stars: ✭ 34 (-12.82%)
Mutual labels:  deno
rippledb
Embeddable key-value database engine in pure TypeScript, based on LSM-Tree
Stars: ✭ 33 (-15.38%)
Mutual labels:  deno
database
towards a common interface for SQL databases in Deno TypeScript
Stars: ✭ 15 (-61.54%)
Mutual labels:  deno
lmdb-js
Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Stars: ✭ 270 (+592.31%)
Mutual labels:  deno
vscode-deno-extensionpack
Deno VS Code Extension Pack
Stars: ✭ 12 (-69.23%)
Mutual labels:  deno
IJProgressView
A simple progress view written in Swift.
Stars: ✭ 70 (+79.49%)
Mutual labels:  progress-bar
deno-task-runner
Task runner for deno
Stars: ✭ 31 (-20.51%)
Mutual labels:  deno
hex
An ecosystem delivering practices, philosophy and portability. Powered By Deno and JavaScript.
Stars: ✭ 48 (+23.08%)
Mutual labels:  deno
iam-policies
Iam policies implementation for create roles and manage permissions
Stars: ✭ 20 (-48.72%)
Mutual labels:  deno
laravel-console-spinner
Customized loading ⌛ spinner for Laravel Artisan Console.
Stars: ✭ 70 (+79.49%)
Mutual labels:  progress-bar
bundle
An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
Stars: ✭ 475 (+1117.95%)
Mutual labels:  deno
merlin
Testing and Benchmarking framework for deno 🧙‍♂️
Stars: ✭ 46 (+17.95%)
Mutual labels:  deno
Proglog
📝 Logs and progress bars manager for Python
Stars: ✭ 87 (+123.08%)
Mutual labels:  progress-bar
deno-drash-realworld-example-app
Deno + Drash RealWorld example app
Stars: ✭ 56 (+43.59%)
Mutual labels:  deno
LinearProgressView
A simple linear progress view for iOS
Stars: ✭ 103 (+164.1%)
Mutual labels:  progress-bar
deno-fetch-event-adapter
Dispatches global fetch events using Deno's native http server.
Stars: ✭ 18 (-53.85%)
Mutual labels:  deno
i18next-http-backend
i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
Stars: ✭ 270 (+592.31%)
Mutual labels:  deno

ProgressBar

ProgressBar in terminal for deno

logo

Update

v1.2.6 - 2022.5.30

Add option to show ETA.

v1.2.0 - 2020.12.5

Add support for "Render multiple progress bars"
Thanks "shixiaobao17145" for the great idea.

v1.1.1 - 2020.07.15

changes: add mod.unstable.ts and ./exmaples/width.unstable.ts

Deno v1.2.0 started to support tty column, but is unstable

deno run --unstable ./examples/width.unstable.ts

Usage

Multiple progress bars

example

import { MultiProgressBar } from "https://deno.land/x/[email protected]/mod.ts";

const title = "download files";
const total = 100;

const bars = new MultiProgressBar({
  title,
  // clear: true,
  complete: "=",
  incomplete: "-",
  display: "[:bar] :text :percent :time :completed/:total",
});

let completed1 = 0;
let completed2 = 0;

function downloading() {
  if (completed1 <= total || completed2 <= total) {
    completed1 += 1;
    completed2 += 2;
    bars.render([
      {
        completed: completed1,
        total,
        text: "file1",
        // You can also change the style of the progress bar
        // complete: "*",
        // incomplete: ".",
      },
      { completed: completed2, total, text: "file2" },
    ]);

    setTimeout(function () {
      downloading();
    }, 100);
  }
}

downloading();

interface

interface constructorOptions {
  title?: string;
  width?: number;
  complete?: string;
  incomplete?: string;
  clear?: boolean;
  interval?: number;
  display?: string;
}
interface renderOptions {
  completed: number;
  text?: string;
  total?: number;
  complete?: string;
  incomplete?: string;
}
class MultiProgressBar {
  /**
   * Title, total, complete, incomplete, can also be set or changed in the render method
   *
   * @param title Progress bar title, default: ''
   * @param width the displayed width of the progress, default: 50
   * @param complete completion character, default: colors.bgGreen(' '), can use any string
   * @param incomplete incomplete character, default: colors.bgWhite(' '), can use any string
   * @param clear  clear the bar on completion, default: false
   * @param interval  minimum time between updates in milliseconds, default: 16
   * @param display  What is displayed and display order, default: ':bar :text :percent :time :completed/:total'
   */
  constructor(optopns: ConstructorOptions);

  /**
   * "render" the progress bar
   *
   * - `bars` progress bars
   *   - `completed` completed value
   *   - `total` optional, total number of ticks to complete, default: 100
   *   - `text` optional, text displayed per ProgressBar, default: ''
   *   - `complete` - optional, completion character
   *   - `incomplete` - optional, incomplete character
   */
  render(bars: Array<renderOptions>): void;

  /**
   * console: interrupt the progress bar and write a message above it
   *
   * @param message The message to write
   */
  console(message: string): void;

  /**
   * end: end a progress bar.
   * No need to call in most cases, unless you want to end before 100%
   */
  end(): void;
}

display

What is displayed and display order, default: ':bar :text :percent :time :completed/:total'

  • :bar the progress bar itself
  • :text text displayed per ProgressBar
  • :percent completion percentage
  • :time time elapsed in seconds
  • :eta estimated completion time in seconds
  • :total total number of ticks to complete
  • :completed completed value

Single progress bar

simple example

import ProgressBar from "https://deno.land/x/[email protected]/mod.ts";

const title = "downloading:";
const total = 100;
const progress = new ProgressBar({
  title,
  total,
});
let completed = 0;
function downloading() {
  if (completed <= total) {
    progress.render(completed++);

    setTimeout(function () {
      downloading();
    }, 100);
  }
}
downloading();

complex example

import ProgressBar from "https://deno.land/x/[email protected]/mod.ts";

const total = 100;
const progress = new ProgressBar({
  total,
  complete: "=",
  incomplete: "-",
  display: ":completed/:total hello :time [:bar] :percent",
  // or =>
  // display: ':bar'
  // display: ':bar :time'
  // display: '[:bar]'
  // display: 'hello :bar world'
  // ...
});
let completed = 0;
function run() {
  if (completed <= total) {
    progress.render(completed++);

    setTimeout(function () {
      run();
    }, 100);
  }
}
run();

More examples in the examples folder.

interface

interface ConstructorOptions {
  title?: string, 
  total?: number, 
  width?: number, 
  complete?: string, 
  preciseBar?: string[], 
  incomplete?: string, 
  clear?: boolean, 
  interval?: number, 
  display?: string
}

interface renderOptions {
  title?: string, 
  total?: number, 
  complete?: string, 
  preciseBar?: string[], 
  incomplete?: string, 
}

class ProgressBar {
  /**  
   * Title, total, complete, incomplete, can also be set or changed in the render method 
   * 
   * @param title progress bar title, default: ''
   * @param total total number of ticks to complete
   * @param width the displayed width of the progress, default: 50
   * @param complete completion character, default: colors.bgGreen(' '), can use any string
   * @param preciseBar in between character, default: [colors.bgGreen(' ')], can use any string array
   * @param incomplete incomplete character, default: colors.bgWhite(' '), can use any string
   * @param clear  clear the bar on completion, default: false
   * @param interval  minimum time between updates in milliseconds, default: 16
   * @param display  What is displayed and display order, default: ':title :percent :bar :time :completed/:total'
   */
  constructor(optopns: ConstructorOptions): void; 

  /**
   * render: render the progress bar
   * 
   * @param completed completed value
   * @param options optional parameters
   * @param options.title progress bar title
   * @param options.total optional, total number of ticks to complete, default: 100
   * @param options.complete completion character, If you want to change at a certain moment. For example, it turns red at 20%
   * @param options.incomplete incomplete character, If you want to change at a certain moment. For example, it turns red at 20%
   */
  render(completed: number, options? renderOptions): void; 

  /**
   * console: interrupt the progress bar and write a message above it
   * 
   * @param message The message to write
   */
  console(message: string): void; 

  /**
   * end: end a progress bar.
   * No need to call in most cases, unless you want to end before 100%
   */
  end(): void; 
}

display

What is displayed and display order, default: ':title :percent :bar :time :completed/:total'

  • :title progress bar title
  • :percent completion percentage
  • :bar the progress bar itself
  • :time time elapsed in seconds
  • :eta estimated completion time in seconds
  • :completed completed value
  • :total total number of ticks to complete

Screenshots

Standard use

normal

Multi-line progress bar output in terminal

normal

Change how the order and look of elements

console

Change character color

console

Change background color

console

Color that changes with progress

console

Precise bar with more intermediate states

console

Wider bar

console

Clear the bar once finished

clear

Backward progress

backward

Log some messages

console

Log some messages next to the bar

console

More screenshots in the screenshots folder.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].