MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //opt/lck-backend/node_modules/image-q/src/utils/progressTracker.ts
export class ProgressTracker {
  static readonly steps = 100;

  progress: number;

  private _step: number;
  private _range: number;
  private _last: number;
  private _progressRange: number;

  constructor(valueRange: number, progressRange: number) {
    this._range = valueRange;
    this._progressRange = progressRange;
    this._step = Math.max(1, (this._range / (ProgressTracker.steps + 1)) | 0);
    this._last = -this._step;
    this.progress = 0;
  }

  shouldNotify(current: number) {
    if (current - this._last >= this._step) {
      this._last = current;
      this.progress = Math.min(
        (this._progressRange * this._last) / this._range,
        this._progressRange,
      );
      return true;
    }

    return false;
  }
}