@types/cli-progress

  • Version 3.11.0
  • Published
  • 13.4 kB
  • 1 dependency
  • MIT license

Install

npm i @types/cli-progress
yarn add @types/cli-progress
pnpm add @types/cli-progress

Overview

TypeScript definitions for cli-progress

Index

Variables

variable defaultFormatter

const defaultFormatter: GenericFormatter;

    variable Format

    const Format: {
    Formatter: typeof defaultFormatter;
    BarFormat: typeof formatBar;
    ValueFormat: typeof formatValue;
    TimeFormat: typeof formatTime;
    };

      variable formatBar

      const formatBar: BarFormatter;

        variable formatTime

        const formatTime: TimeFormatter;

          variable formatValue

          const formatValue: ValueFormatter;

            variable Presets

            const Presets: {
            legacy: Preset;
            rect: Preset;
            shades_classic: Preset;
            shades_grey: Preset;
            };

              Classes

              class Bar

              class Bar extends SingleBar {}

                class GenericBar

                class GenericBar extends EventEmitter {}

                  constructor

                  constructor(opt: Options, preset?: Preset);
                  • Initialize a new Progress bar. An instance can be used multiple times! it's not required to re-create it!

                  method getProgress

                  getProgress: () => number;
                  • Calculate the actual progress value

                  method getTotal

                  getTotal: () => number;
                  • Get the total (limit) value

                  method increment

                  increment: { (step?: number, payload?: object): void; (payload: object): void };
                  • Increases the current progress value by a specified amount (default +1). Update payload optionally

                  method render

                  render: (forceRendering?: boolean) => void;
                  • Internal render function

                  method setTotal

                  setTotal: (total: number) => void;
                  • Sets the total progress value while progressbar is active. Especially useful handling dynamic tasks.

                  method start

                  start: (total: number, startValue: number, payload?: object) => void;
                  • Starts the progress bar and set the total and initial value

                  method stop

                  stop: () => void;
                  • Stops the progress bar and go to next line

                  method update

                  update: { (current: number, payload?: object): void; (payload: object): void };
                  • Sets the current progress value and optionally the payload with values of custom tokens as a second parameter

                  method updateETA

                  updateETA: () => void;
                  • Force eta calculation update (long running processes) without altering the progress values.

                  class MultiBar

                  class MultiBar extends EventEmitter {}

                    constructor

                    constructor(opt: Options, preset?: Preset);

                      method create

                      create: (
                      total: number,
                      startValue: number,
                      payload?: any,
                      barOptions?: Options
                      ) => SingleBar;
                      • add a new bar to the stack

                      method log

                      log: (data: string) => void;
                      • log output above the progress bars; string must end with newline character!

                      method remove

                      remove: (bar: SingleBar) => boolean;
                      • remove a bar from the stack

                      method stop

                      stop: () => void;

                        method update

                        update: () => void;
                        • internal update routine

                        class SingleBar

                        class SingleBar extends GenericBar {}

                          constructor

                          constructor(opt: Options, preset?: Preset);
                          • Initialize a new Progress bar. An instance can be used multiple times! it's not required to re-create it!

                          method render

                          render: () => void;
                          • Internal render function

                          method start

                          start: (total: number, startValue: number, payload?: object) => void;
                          • Starts the progress bar and set the total and initial value

                          method stop

                          stop: () => void;
                          • Stops the progress bar and go to next line

                          method update

                          update: { (current: number, payload?: object): void; (payload: object): void };
                          • Sets the current progress value and optionally the payload with values of custom tokens as a second parameter

                          Interfaces

                          interface BarFormatter

                          interface BarFormatter {}

                            call signature

                            (progress: number, options: Options): string;

                              interface GenericFormatter

                              interface GenericFormatter {}

                                call signature

                                (options: Options, params: Params, payload: any): string;

                                  interface Options

                                  interface Options {}

                                    property align

                                    align?: 'left' | 'right' | 'center' | undefined;
                                    • position of the progress bar - 'left' (default), 'right' or 'center

                                    property autopadding

                                    autopadding?: boolean | undefined;
                                    • add padding chars to formatted time and percentage to force fixed width (default: false)

                                    property autopaddingChar

                                    autopaddingChar?: string | undefined;
                                    • the character sequence used for autopadding (default: " ")

                                    property barCompleteChar

                                    barCompleteChar?: string | undefined;
                                    • character to use as "complete" indicator in the bar (default: "=")

                                    property barCompleteString

                                    barCompleteString?: string | undefined;
                                    • character to use as "complete" indicator in the bar (default: "=")

                                    property barGlue

                                    barGlue?: string | undefined;
                                    • glue sequence (control chars) between bar elements (default: '')

                                    property barIncompleteChar

                                    barIncompleteChar?: string | undefined;
                                    • character to use as "incomplete" indicator in the bar (default: "-")

                                    property barIncompleteString

                                    barIncompleteString?: string | undefined;
                                    • character to use as "incomplete" indicator in the bar (default: "-")

                                    property barsize

                                    barsize?: number | undefined;
                                    • the length of the progress bar in chars (default: 40)

                                    property clearOnComplete

                                    clearOnComplete?: boolean | undefined;
                                    • clear the progress bar on complete / stop() call (default: false)

                                    property emptyOnZero

                                    emptyOnZero?: boolean | undefined;
                                    • display progress bars with 'total' of zero(0) as empty, not full (default: false)

                                    property etaAsynchronousUpdate

                                    etaAsynchronousUpdate?: boolean | undefined;
                                    • trigger an eta calculation update during asynchronous rendering trigger using the current value - should only be used for long running processes in conjunction with lof fps values and large etaBuffer false

                                    property etaBuffer

                                    etaBuffer?: number | undefined;
                                    • number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10)

                                    property forceRedraw

                                    forceRedraw?: boolean | undefined;
                                    • trigger redraw on every frame even if progress remains the same; can be useful if progress bar gets overwritten by other concurrent writes to the terminal (default: false)

                                    property format

                                    format?: string | GenericFormatter | undefined;
                                    • progress bar output format. The progressbar can be customized by using the following build-in placeholders. They can be combined in any order. {bar} - the progress bar, customizable by the options barsize, barCompleteString and barIncompleteString {percentage} - the current progress in percent (0-100) {total} - the end value {value} - the current value set by last update() call {eta} - expected time of accomplishment in seconds {duration} - elapsed time in seconds {eta_formatted} - expected time of accomplishment formatted into appropriate units {duration_formatted} - elapsed time formatted into appropriate units

                                      Example: progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} is rendered as progress [========================================] 100% | ETA: 0s | 200/200

                                    property formatBar

                                    formatBar?: BarFormatter | undefined;
                                    • a custom bar formatter function which renders the bar-element (default: format-bar.js)

                                    property formatTime

                                    formatTime?: TimeFormatter | undefined;
                                    • a custom timer formatter function which renders the formatted time elements like eta_formatted and duration-formatted (default: format-time.js)

                                    property formatValue

                                    formatValue?: ValueFormatter | undefined;
                                    • a custom value formatter function which renders all other values (default: format-value.js)

                                    property fps

                                    fps?: number | undefined;
                                    • the maximum update rate (default: 10)

                                    property gracefulExit

                                    gracefulExit?: boolean | undefined;
                                    • stop bar on SIGINT/SIGTERM to restore cursor settings (default: true)

                                    property hideCursor

                                    hideCursor?: boolean | null | undefined;
                                    • hide the cursor during progress operation; restored on complete (default: false) - pass null to keep terminal settings

                                    property linewrap

                                    linewrap?: boolean | null | undefined;
                                    • disable line wrapping (default: false) - pass null to keep terminal settings; pass true to trim the output to terminal width

                                    property notTTYSchedule

                                    notTTYSchedule?: number | undefined;
                                    • set the output schedule/interval for notty output in ms (default: 2000ms)

                                    property noTTYOutput

                                    noTTYOutput?: boolean | undefined;
                                    • enable scheduled output to notty streams - e.g. redirect to files (default: false)

                                    property progressCalculationRelative

                                    progressCalculationRelative?: boolean | undefined;
                                    • progress calculation relative to start value ? default start at 0 (default: false)

                                    property stopOnComplete

                                    stopOnComplete?: boolean | undefined;
                                    • automatically call stop() when the value reaches the total (default: false)

                                    property stream

                                    stream?: NodeJS.WritableStream | undefined;
                                    • output stream to use (default: process.stderr)

                                    property synchronousUpdate

                                    synchronousUpdate?: boolean | undefined;
                                    • trigger redraw during update() in case threshold time x2 is exceeded (default: true) - limited to single bar usage

                                    interface Params

                                    interface Params {}

                                      property eta

                                      eta: number;

                                        property maxWidth

                                        maxWidth: number;

                                          property progress

                                          progress: number;

                                            property startTime

                                            startTime: number;

                                              property total

                                              total: number;

                                                property value

                                                value: number;

                                                  interface Preset

                                                  interface Preset {}

                                                    property barCompleteChar

                                                    barCompleteChar: string;

                                                      property barIncompleteChar

                                                      barIncompleteChar: string;

                                                        property format

                                                        format: string;
                                                        • Example: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}'

                                                          {bar} - the progress bar, customizable by the options barsize, barCompleteString and barIncompleteString

                                                          {percentage} - the current progress in percent (0-100)

                                                          {total} - the end value

                                                          {value} - the current value set by last update() call

                                                          {eta} - expected time of accomplishment in seconds (limited to 115days, otherwise INF is displayed)

                                                          {duration} - elapsed time in seconds

                                                          {eta_formatted} - expected time of accomplishment formatted into appropriate units

                                                          {duration_formatted} - elapsed time formatted into appropriate units

                                                        interface TimeFormatter

                                                        interface TimeFormatter {}

                                                          call signature

                                                          (t: number, options: Options, roundToMultipleOf: number): string;

                                                            interface ValueFormatter

                                                            interface ValueFormatter {}

                                                              call signature

                                                              (v: number, options: Options, type: ValueType): string;

                                                                Type Aliases

                                                                type ValueType

                                                                type ValueType = 'percentage' | 'total' | 'value' | 'eta' | 'duration';

                                                                  Package Files (1)

                                                                  Dependencies (1)

                                                                  Dev Dependencies (0)

                                                                  No dev dependencies.

                                                                  Peer Dependencies (0)

                                                                  No peer dependencies.

                                                                  Badge

                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/cli-progress.

                                                                  • Markdown
                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/cli-progress)
                                                                  • HTML
                                                                    <a href="https://www.jsdocs.io/package/@types/cli-progress"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>