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/chevrotain/src/lang/lang_extensions.ts
import { TokenType } from "../../api"
import { isUndefined } from "../utils/utils"

export function classNameFromInstance(instance: any): string {
  return functionName(instance.constructor)
}

const NAME = "name"

/**
 * Utility to obtain Function names.
 * Note that there should not be an assumptions on the result of this function.
 * E.g: When running from minified source code the result may be auto generated.
 */
export function functionName(func: TokenType): string {
  // Engines that support Function.prototype.name OR the nth (n>1) time after
  // the name has been computed in the following else block.
  let existingNameProp = (<any>func).name
  /* istanbul ignore else - too many hacks for IE/old versions of node.js here*/
  if (existingNameProp) {
    return existingNameProp
  } else {
    return "anonymous"
  }
}

/**
 * @returns {boolean} - has the property been successfully defined
 */
export function defineNameProp(obj, nameValue): boolean {
  let namePropDescriptor = Object.getOwnPropertyDescriptor(obj, NAME)
  /* istanbul ignore else -> will only run in old versions of node.js */
  if (isUndefined(namePropDescriptor) || namePropDescriptor.configurable) {
    Object.defineProperty(obj, NAME, {
      enumerable: false,
      configurable: true,
      writable: false,
      value: nameValue
    })

    return true
  }
  /* istanbul ignore next -> will only run in old versions of node.js */
  return false
}