vlocode-project - v2.4.3
    Preparing search index...

    Class ProgressTracker

    Tracks the numbers behind a long-running operation and derives presentation-ready metrics from them: completion ratio, percentage, throughput, ETA and elapsed time.

    The tracker is the model behind ProgressBar but is independent of any rendering: it can be used on its own to compute progress figures, or shared with a bar so the bar and another consumer (a logger, a status line, …) present identical numbers.

    It is built for sources whose total is discovered incrementally — report(value, total) simply overwrites the latest reading, and total may grow over time. The visual ratio is always clamped to [0, 1], and ProgressTrackerOptions.minTotal provides a floor so the bar does not look complete before the real amount of work is known.

    const progress = new ProgressTracker({ label: 'Downloading', minTotal: 100 });
    progress.report(40, 100);
    progress.percent; // 40
    progress.summary(); // '40% (40/100) · 12/s · ETA 0:05'
    Index

    Constructors

    Properties

    currentTotal: number = 0
    currentValue: number = 0
    label: string

    Short label describing the operation. Freely mutable so callers can relabel between phases.

    message: string = ''

    Free-form trailing text, e.g. the item currently being processed.

    minTotal: number
    timer: Timer = ...

    Accessors

    • get eta(): number | undefined

      Estimated seconds remaining based on the current rate, or undefined when it cannot be computed yet (no rate, unknown total, or already complete). Self-corrects as the total grows.

      Returns number | undefined

    • get indeterminate(): boolean

      True while no meaningful total is known yet, in which case progress cannot be expressed as a fraction and a renderer should fall back to an indeterminate animation.

      Returns boolean

    • get ratio(): number

      Completion ratio in the [0, 1] range, clamped so a lagging total (the total can jump up as new work is discovered) never produces a ratio above 1.

      Returns number

    • get timeText(): string

      Time column for a gauge: the time the task is running. Estimates (ETA) and throughput rates fluctuate too much across the phases of a run to be meaningful; a climbing elapsed time is always accurate and keeps visibly moving while a long phase runs.

      Returns string

    Methods

    • Integer milestone index for throttling output, e.g. milestone(10) returns 0..10 as progress passes each 10% mark.

      Parameters

      • step: number

      Returns number

    • Record the latest progress. Either argument may be omitted to leave it unchanged. The source is expected to report a total that can grow as more work is discovered; the most recent reading is always kept.

      Parameters

      • Optionalvalue: number
      • Optionaltotal: number

      Returns void

    • Reset the gauge to zero for a fresh progression (e.g. a new phase of work): clears the counts, applies a new lower bound for the total and restarts the clock so throughput and ETA are scoped to the new progression.

      Parameters

      • minTotal: number = 0

      Returns void