HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/node_modules/eventemitter-asyncresource/src/index.ts
import { EventEmitter } from 'events';
import { AsyncResource } from 'async_hooks';

const kEventEmitter = Symbol('kEventEmitter');
const kAsyncResource = Symbol('kAsyncResource');

type EventEmitterOptions = typeof EventEmitter extends {
  new (options?: infer T) : EventEmitter;
} ? T : never;

type AsyncResourceOptions = typeof AsyncResource extends {
  new (name : string, options?: infer T) : AsyncResource;
} ? T : never;

type Options = EventEmitterOptions & AsyncResourceOptions & {
  name?: string;
};

class EventEmitterReferencingAsyncResource extends AsyncResource {
  [kEventEmitter] : EventEmitter;

  constructor (ee: EventEmitter, type: string, options?: AsyncResourceOptions) {
    super(type, options);
    this[kEventEmitter] = ee;
  }

  get eventEmitter () : EventEmitter {
    return this[kEventEmitter];
  }
}

class EventEmitterAsyncResource extends EventEmitter {
  [kAsyncResource] : EventEmitterReferencingAsyncResource;

  constructor (options?: Options | string) {
    let name;
    if (typeof options === 'string') {
      name = options;
      options = undefined;
    } else {
      name = options?.name || new.target.name;
    }
    super(options);

    this[kAsyncResource] =
      new EventEmitterReferencingAsyncResource(this, name, options);
  }

  emit (event: string | symbol, ...args: any[]) : boolean {
    return this.asyncResource.runInAsyncScope(
      super.emit, this, event, ...args);
  }

  emitDestroy () : void {
    this.asyncResource.emitDestroy();
  }

  asyncId () : number {
    return this.asyncResource.asyncId();
  }

  triggerAsyncId () : number {
    return this.asyncResource.triggerAsyncId();
  }

  get asyncResource () : EventEmitterReferencingAsyncResource {
    return this[kAsyncResource];
  }

  static get EventEmitterAsyncResource () { return EventEmitterAsyncResource; }
}

export = EventEmitterAsyncResource;