HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //opt/alt/alt-nodejs20/root/lib/node_modules/npm/node_modules/proggy/lib/tracker.js
// The tracker class is intentionally as naive as possible.  it is just
// an ergonomic wrapper around process.emit('progress', ...)
const EE = require('events')
class Tracker extends EE {
  constructor (name, key, total) {
    super()
    if (!name) {
      throw new Error('proggy: Tracker needs a name')
    }

    if (typeof key === 'number' && !total) {
      total = key
      key = null
    }

    if (!total) {
      total = 100
    }

    if (!key) {
      key = name
    }

    this.done = false
    this.name = name
    this.key = key
    this.value = 0
    this.total = total
  }

  finish (metadata = {}) {
    this.update(this.total, this.total, metadata)
  }

  update (value, total, metadata) {
    if (!metadata) {
      if (total && typeof total === 'object') {
        metadata = total
      } else {
        metadata = {}
      }
    }
    if (typeof total !== 'number') {
      total = this.total
    }

    if (this.done) {
      const msg = `proggy: updating completed tracker: ${JSON.stringify(this.key)}`
      throw new Error(msg)
    }
    this.value = value
    this.total = total
    const done = this.value >= this.total
    process.emit('progress', this.key, {
      ...metadata,
      name: this.name,
      key: this.key,
      value,
      total,
      done,
    })
    if (done) {
      this.done = true
      this.emit('done')
    }
  }
}
module.exports = Tracker