githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

process.d.ts (77415B)


      1 declare module "process" {
      2     import * as tty from "node:tty";
      3     import { Worker } from "node:worker_threads";
      4     global {
      5         var process: NodeJS.Process;
      6         namespace NodeJS {
      7             // this namespace merge is here because these are specifically used
      8             // as the type for process.stdin, process.stdout, and process.stderr.
      9             // they can't live in tty.d.ts because we need to disambiguate the imported name.
     10             interface ReadStream extends tty.ReadStream {}
     11             interface WriteStream extends tty.WriteStream {}
     12             interface MemoryUsageFn {
     13                 /**
     14                  * The `process.memoryUsage()` method iterate over each page to gather informations about memory
     15                  * usage which can be slow depending on the program memory allocations.
     16                  */
     17                 (): MemoryUsage;
     18                 /**
     19                  * method returns an integer representing the Resident Set Size (RSS) in bytes.
     20                  */
     21                 rss(): number;
     22             }
     23             interface MemoryUsage {
     24                 rss: number;
     25                 heapTotal: number;
     26                 heapUsed: number;
     27                 external: number;
     28                 arrayBuffers: number;
     29             }
     30             interface CpuUsage {
     31                 user: number;
     32                 system: number;
     33             }
     34             interface ProcessRelease {
     35                 name: string;
     36                 sourceUrl?: string | undefined;
     37                 headersUrl?: string | undefined;
     38                 libUrl?: string | undefined;
     39                 lts?: string | undefined;
     40             }
     41             interface ProcessVersions extends Dict<string> {
     42                 http_parser: string;
     43                 node: string;
     44                 v8: string;
     45                 ares: string;
     46                 uv: string;
     47                 zlib: string;
     48                 modules: string;
     49                 openssl: string;
     50             }
     51             type Platform =
     52                 | "aix"
     53                 | "android"
     54                 | "darwin"
     55                 | "freebsd"
     56                 | "haiku"
     57                 | "linux"
     58                 | "openbsd"
     59                 | "sunos"
     60                 | "win32"
     61                 | "cygwin"
     62                 | "netbsd";
     63             type Signals =
     64                 | "SIGABRT"
     65                 | "SIGALRM"
     66                 | "SIGBUS"
     67                 | "SIGCHLD"
     68                 | "SIGCONT"
     69                 | "SIGFPE"
     70                 | "SIGHUP"
     71                 | "SIGILL"
     72                 | "SIGINT"
     73                 | "SIGIO"
     74                 | "SIGIOT"
     75                 | "SIGKILL"
     76                 | "SIGPIPE"
     77                 | "SIGPOLL"
     78                 | "SIGPROF"
     79                 | "SIGPWR"
     80                 | "SIGQUIT"
     81                 | "SIGSEGV"
     82                 | "SIGSTKFLT"
     83                 | "SIGSTOP"
     84                 | "SIGSYS"
     85                 | "SIGTERM"
     86                 | "SIGTRAP"
     87                 | "SIGTSTP"
     88                 | "SIGTTIN"
     89                 | "SIGTTOU"
     90                 | "SIGUNUSED"
     91                 | "SIGURG"
     92                 | "SIGUSR1"
     93                 | "SIGUSR2"
     94                 | "SIGVTALRM"
     95                 | "SIGWINCH"
     96                 | "SIGXCPU"
     97                 | "SIGXFSZ"
     98                 | "SIGBREAK"
     99                 | "SIGLOST"
    100                 | "SIGINFO";
    101             type UncaughtExceptionOrigin = "uncaughtException" | "unhandledRejection";
    102             type MultipleResolveType = "resolve" | "reject";
    103             type BeforeExitListener = (code: number) => void;
    104             type DisconnectListener = () => void;
    105             type ExitListener = (code: number) => void;
    106             type RejectionHandledListener = (promise: Promise<unknown>) => void;
    107             type UncaughtExceptionListener = (error: Error, origin: UncaughtExceptionOrigin) => void;
    108             /**
    109              * Most of the time the unhandledRejection will be an Error, but this should not be relied upon
    110              * as *anything* can be thrown/rejected, it is therefore unsafe to assume the the value is an Error.
    111              */
    112             type UnhandledRejectionListener = (reason: unknown, promise: Promise<unknown>) => void;
    113             type WarningListener = (warning: Error) => void;
    114             type MessageListener = (message: unknown, sendHandle: unknown) => void;
    115             type SignalsListener = (signal: Signals) => void;
    116             type MultipleResolveListener = (
    117                 type: MultipleResolveType,
    118                 promise: Promise<unknown>,
    119                 value: unknown,
    120             ) => void;
    121             type WorkerListener = (worker: Worker) => void;
    122             interface Socket extends ReadWriteStream {
    123                 isTTY?: true | undefined;
    124             }
    125             // Alias for compatibility
    126             interface ProcessEnv extends Dict<string> {
    127                 /**
    128                  * Can be used to change the default timezone at runtime
    129                  */
    130                 TZ?: string;
    131             }
    132             interface HRTime {
    133                 /**
    134                  * This is the legacy version of {@link process.hrtime.bigint()}
    135                  * before bigint was introduced in JavaScript.
    136                  *
    137                  * The `process.hrtime()` method returns the current high-resolution real time in a `[seconds, nanoseconds]` tuple `Array`,
    138                  * where `nanoseconds` is the remaining part of the real time that can't be represented in second precision.
    139                  *
    140                  * `time` is an optional parameter that must be the result of a previous `process.hrtime()` call to diff with the current time.
    141                  * If the parameter passed in is not a tuple `Array`, a TypeError will be thrown.
    142                  * Passing in a user-defined array instead of the result of a previous call to `process.hrtime()` will lead to undefined behavior.
    143                  *
    144                  * These times are relative to an arbitrary time in the past,
    145                  * and not related to the time of day and therefore not subject to clock drift.
    146                  * The primary use is for measuring performance between intervals:
    147                  * ```js
    148                  * const { hrtime } = require('node:process');
    149                  * const NS_PER_SEC = 1e9;
    150                  * const time = hrtime();
    151                  * // [ 1800216, 25 ]
    152                  *
    153                  * setTimeout(() => {
    154                  *   const diff = hrtime(time);
    155                  *   // [ 1, 552 ]
    156                  *
    157                  *   console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
    158                  *   // Benchmark took 1000000552 nanoseconds
    159                  * }, 1000);
    160                  * ```
    161                  * @since 0.7.6
    162                  * @legacy Use {@link process.hrtime.bigint()} instead.
    163                  * @param time The result of a previous call to `process.hrtime()`
    164                  */
    165                 (time?: [number, number]): [number, number];
    166                 /**
    167                  * The `bigint` version of the {@link process.hrtime()} method returning the current high-resolution real time in nanoseconds as a `bigint`.
    168                  *
    169                  * Unlike {@link process.hrtime()}, it does not support an additional time argument since the difference can just be computed directly by subtraction of the two `bigint`s.
    170                  * ```js
    171                  * import { hrtime } from 'node:process';
    172                  *
    173                  * const start = hrtime.bigint();
    174                  * // 191051479007711n
    175                  *
    176                  * setTimeout(() => {
    177                  *   const end = hrtime.bigint();
    178                  *   // 191052633396993n
    179                  *
    180                  *   console.log(`Benchmark took ${end - start} nanoseconds`);
    181                  *   // Benchmark took 1154389282 nanoseconds
    182                  * }, 1000);
    183                  * ```
    184                  * @since v10.7.0
    185                  */
    186                 bigint(): bigint;
    187             }
    188             interface ProcessReport {
    189                 /**
    190                  * Directory where the report is written.
    191                  * working directory of the Node.js process.
    192                  * @default '' indicating that reports are written to the current
    193                  */
    194                 directory: string;
    195                 /**
    196                  * Filename where the report is written.
    197                  * The default value is the empty string.
    198                  * @default '' the output filename will be comprised of a timestamp,
    199                  * PID, and sequence number.
    200                  */
    201                 filename: string;
    202                 /**
    203                  * Returns a JSON-formatted diagnostic report for the running process.
    204                  * The report's JavaScript stack trace is taken from err, if present.
    205                  */
    206                 getReport(err?: Error): string;
    207                 /**
    208                  * If true, a diagnostic report is generated on fatal errors,
    209                  * such as out of memory errors or failed C++ assertions.
    210                  * @default false
    211                  */
    212                 reportOnFatalError: boolean;
    213                 /**
    214                  * If true, a diagnostic report is generated when the process
    215                  * receives the signal specified by process.report.signal.
    216                  * @default false
    217                  */
    218                 reportOnSignal: boolean;
    219                 /**
    220                  * If true, a diagnostic report is generated on uncaught exception.
    221                  * @default false
    222                  */
    223                 reportOnUncaughtException: boolean;
    224                 /**
    225                  * The signal used to trigger the creation of a diagnostic report.
    226                  * @default 'SIGUSR2'
    227                  */
    228                 signal: Signals;
    229                 /**
    230                  * Writes a diagnostic report to a file. If filename is not provided, the default filename
    231                  * includes the date, time, PID, and a sequence number.
    232                  * The report's JavaScript stack trace is taken from err, if present.
    233                  *
    234                  * @param fileName Name of the file where the report is written.
    235                  * This should be a relative path, that will be appended to the directory specified in
    236                  * `process.report.directory`, or the current working directory of the Node.js process,
    237                  * if unspecified.
    238                  * @param error A custom error used for reporting the JavaScript stack.
    239                  * @return Filename of the generated report.
    240                  */
    241                 writeReport(fileName?: string): string;
    242                 writeReport(error?: Error): string;
    243                 writeReport(fileName?: string, err?: Error): string;
    244             }
    245             interface ResourceUsage {
    246                 fsRead: number;
    247                 fsWrite: number;
    248                 involuntaryContextSwitches: number;
    249                 ipcReceived: number;
    250                 ipcSent: number;
    251                 majorPageFault: number;
    252                 maxRSS: number;
    253                 minorPageFault: number;
    254                 sharedMemorySize: number;
    255                 signalsCount: number;
    256                 swappedOut: number;
    257                 systemCPUTime: number;
    258                 unsharedDataSize: number;
    259                 unsharedStackSize: number;
    260                 userCPUTime: number;
    261                 voluntaryContextSwitches: number;
    262             }
    263             interface EmitWarningOptions {
    264                 /**
    265                  * When `warning` is a `string`, `type` is the name to use for the _type_ of warning being emitted.
    266                  *
    267                  * @default 'Warning'
    268                  */
    269                 type?: string | undefined;
    270                 /**
    271                  * A unique identifier for the warning instance being emitted.
    272                  */
    273                 code?: string | undefined;
    274                 /**
    275                  * When `warning` is a `string`, `ctor` is an optional function used to limit the generated stack trace.
    276                  *
    277                  * @default process.emitWarning
    278                  */
    279                 ctor?: Function | undefined;
    280                 /**
    281                  * Additional text to include with the error.
    282                  */
    283                 detail?: string | undefined;
    284             }
    285             interface ProcessConfig {
    286                 readonly target_defaults: {
    287                     readonly cflags: any[];
    288                     readonly default_configuration: string;
    289                     readonly defines: string[];
    290                     readonly include_dirs: string[];
    291                     readonly libraries: string[];
    292                 };
    293                 readonly variables: {
    294                     readonly clang: number;
    295                     readonly host_arch: string;
    296                     readonly node_install_npm: boolean;
    297                     readonly node_install_waf: boolean;
    298                     readonly node_prefix: string;
    299                     readonly node_shared_openssl: boolean;
    300                     readonly node_shared_v8: boolean;
    301                     readonly node_shared_zlib: boolean;
    302                     readonly node_use_dtrace: boolean;
    303                     readonly node_use_etw: boolean;
    304                     readonly node_use_openssl: boolean;
    305                     readonly target_arch: string;
    306                     readonly v8_no_strict_aliasing: number;
    307                     readonly v8_use_snapshot: boolean;
    308                     readonly visibility: string;
    309                 };
    310             }
    311             interface Process extends EventEmitter {
    312                 /**
    313                  * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is
    314                  * a `Writable` stream.
    315                  *
    316                  * For example, to copy `process.stdin` to `process.stdout`:
    317                  *
    318                  * ```js
    319                  * import { stdin, stdout } from 'process';
    320                  *
    321                  * stdin.pipe(stdout);
    322                  * ```
    323                  *
    324                  * `process.stdout` differs from other Node.js streams in important ways. See `note on process I/O` for more information.
    325                  */
    326                 stdout: WriteStream & {
    327                     fd: 1;
    328                 };
    329                 /**
    330                  * The `process.stderr` property returns a stream connected to`stderr` (fd `2`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `2` refers to a file, in which case it is
    331                  * a `Writable` stream.
    332                  *
    333                  * `process.stderr` differs from other Node.js streams in important ways. See `note on process I/O` for more information.
    334                  */
    335                 stderr: WriteStream & {
    336                     fd: 2;
    337                 };
    338                 /**
    339                  * The `process.stdin` property returns a stream connected to`stdin` (fd `0`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `0` refers to a file, in which case it is
    340                  * a `Readable` stream.
    341                  *
    342                  * For details of how to read from `stdin` see `readable.read()`.
    343                  *
    344                  * As a `Duplex` stream, `process.stdin` can also be used in "old" mode that
    345                  * is compatible with scripts written for Node.js prior to v0.10\.
    346                  * For more information see `Stream compatibility`.
    347                  *
    348                  * In "old" streams mode the `stdin` stream is paused by default, so one
    349                  * must call `process.stdin.resume()` to read from it. Note also that calling`process.stdin.resume()` itself would switch stream to "old" mode.
    350                  */
    351                 stdin: ReadStream & {
    352                     fd: 0;
    353                 };
    354                 openStdin(): Socket;
    355                 /**
    356                  * The `process.argv` property returns an array containing the command-line
    357                  * arguments passed when the Node.js process was launched. The first element will
    358                  * be {@link execPath}. See `process.argv0` if access to the original value
    359                  * of `argv[0]` is needed. The second element will be the path to the JavaScript
    360                  * file being executed. The remaining elements will be any additional command-line
    361                  * arguments.
    362                  *
    363                  * For example, assuming the following script for `process-args.js`:
    364                  *
    365                  * ```js
    366                  * import { argv } from 'process';
    367                  *
    368                  * // print process.argv
    369                  * argv.forEach((val, index) => {
    370                  *   console.log(`${index}: ${val}`);
    371                  * });
    372                  * ```
    373                  *
    374                  * Launching the Node.js process as:
    375                  *
    376                  * ```console
    377                  * $ node process-args.js one two=three four
    378                  * ```
    379                  *
    380                  * Would generate the output:
    381                  *
    382                  * ```text
    383                  * 0: /usr/local/bin/node
    384                  * 1: /Users/mjr/work/node/process-args.js
    385                  * 2: one
    386                  * 3: two=three
    387                  * 4: four
    388                  * ```
    389                  * @since v0.1.27
    390                  */
    391                 argv: string[];
    392                 /**
    393                  * The `process.argv0` property stores a read-only copy of the original value of`argv[0]` passed when Node.js starts.
    394                  *
    395                  * ```console
    396                  * $ bash -c 'exec -a customArgv0 ./node'
    397                  * > process.argv[0]
    398                  * '/Volumes/code/external/node/out/Release/node'
    399                  * > process.argv0
    400                  * 'customArgv0'
    401                  * ```
    402                  * @since v6.4.0
    403                  */
    404                 argv0: string;
    405                 /**
    406                  * The `process.execArgv` property returns the set of Node.js-specific command-line
    407                  * options passed when the Node.js process was launched. These options do not
    408                  * appear in the array returned by the {@link argv} property, and do not
    409                  * include the Node.js executable, the name of the script, or any options following
    410                  * the script name. These options are useful in order to spawn child processes with
    411                  * the same execution environment as the parent.
    412                  *
    413                  * ```console
    414                  * $ node --harmony script.js --version
    415                  * ```
    416                  *
    417                  * Results in `process.execArgv`:
    418                  *
    419                  * ```js
    420                  * ['--harmony']
    421                  * ```
    422                  *
    423                  * And `process.argv`:
    424                  *
    425                  * ```js
    426                  * ['/usr/local/bin/node', 'script.js', '--version']
    427                  * ```
    428                  *
    429                  * Refer to `Worker constructor` for the detailed behavior of worker
    430                  * threads with this property.
    431                  * @since v0.7.7
    432                  */
    433                 execArgv: string[];
    434                 /**
    435                  * The `process.execPath` property returns the absolute pathname of the executable
    436                  * that started the Node.js process. Symbolic links, if any, are resolved.
    437                  *
    438                  * ```js
    439                  * '/usr/local/bin/node'
    440                  * ```
    441                  * @since v0.1.100
    442                  */
    443                 execPath: string;
    444                 /**
    445                  * The `process.abort()` method causes the Node.js process to exit immediately and
    446                  * generate a core file.
    447                  *
    448                  * This feature is not available in `Worker` threads.
    449                  * @since v0.7.0
    450                  */
    451                 abort(): never;
    452                 /**
    453                  * The `process.chdir()` method changes the current working directory of the
    454                  * Node.js process or throws an exception if doing so fails (for instance, if
    455                  * the specified `directory` does not exist).
    456                  *
    457                  * ```js
    458                  * import { chdir, cwd } from 'process';
    459                  *
    460                  * console.log(`Starting directory: ${cwd()}`);
    461                  * try {
    462                  *   chdir('/tmp');
    463                  *   console.log(`New directory: ${cwd()}`);
    464                  * } catch (err) {
    465                  *   console.error(`chdir: ${err}`);
    466                  * }
    467                  * ```
    468                  *
    469                  * This feature is not available in `Worker` threads.
    470                  * @since v0.1.17
    471                  */
    472                 chdir(directory: string): void;
    473                 /**
    474                  * The `process.cwd()` method returns the current working directory of the Node.js
    475                  * process.
    476                  *
    477                  * ```js
    478                  * import { cwd } from 'process';
    479                  *
    480                  * console.log(`Current directory: ${cwd()}`);
    481                  * ```
    482                  * @since v0.1.8
    483                  */
    484                 cwd(): string;
    485                 /**
    486                  * The port used by the Node.js debugger when enabled.
    487                  *
    488                  * ```js
    489                  * import process from 'process';
    490                  *
    491                  * process.debugPort = 5858;
    492                  * ```
    493                  * @since v0.7.2
    494                  */
    495                 debugPort: number;
    496                 /**
    497                  * The `process.emitWarning()` method can be used to emit custom or application
    498                  * specific process warnings. These can be listened for by adding a handler to the `'warning'` event.
    499                  *
    500                  * ```js
    501                  * import { emitWarning } from 'process';
    502                  *
    503                  * // Emit a warning with a code and additional detail.
    504                  * emitWarning('Something happened!', {
    505                  *   code: 'MY_WARNING',
    506                  *   detail: 'This is some additional information'
    507                  * });
    508                  * // Emits:
    509                  * // (node:56338) [MY_WARNING] Warning: Something happened!
    510                  * // This is some additional information
    511                  * ```
    512                  *
    513                  * In this example, an `Error` object is generated internally by`process.emitWarning()` and passed through to the `'warning'` handler.
    514                  *
    515                  * ```js
    516                  * import process from 'process';
    517                  *
    518                  * process.on('warning', (warning) => {
    519                  *   console.warn(warning.name);    // 'Warning'
    520                  *   console.warn(warning.message); // 'Something happened!'
    521                  *   console.warn(warning.code);    // 'MY_WARNING'
    522                  *   console.warn(warning.stack);   // Stack trace
    523                  *   console.warn(warning.detail);  // 'This is some additional information'
    524                  * });
    525                  * ```
    526                  *
    527                  * If `warning` is passed as an `Error` object, the `options` argument is ignored.
    528                  * @since v8.0.0
    529                  * @param warning The warning to emit.
    530                  */
    531                 emitWarning(warning: string | Error, ctor?: Function): void;
    532                 emitWarning(warning: string | Error, type?: string, ctor?: Function): void;
    533                 emitWarning(warning: string | Error, type?: string, code?: string, ctor?: Function): void;
    534                 emitWarning(warning: string | Error, options?: EmitWarningOptions): void;
    535                 /**
    536                  * The `process.env` property returns an object containing the user environment.
    537                  * See [`environ(7)`](http://man7.org/linux/man-pages/man7/environ.7.html).
    538                  *
    539                  * An example of this object looks like:
    540                  *
    541                  * ```js
    542                  * {
    543                  *   TERM: 'xterm-256color',
    544                  *   SHELL: '/usr/local/bin/bash',
    545                  *   USER: 'maciej',
    546                  *   PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',
    547                  *   PWD: '/Users/maciej',
    548                  *   EDITOR: 'vim',
    549                  *   SHLVL: '1',
    550                  *   HOME: '/Users/maciej',
    551                  *   LOGNAME: 'maciej',
    552                  *   _: '/usr/local/bin/node'
    553                  * }
    554                  * ```
    555                  *
    556                  * It is possible to modify this object, but such modifications will not be
    557                  * reflected outside the Node.js process, or (unless explicitly requested)
    558                  * to other `Worker` threads.
    559                  * In other words, the following example would not work:
    560                  *
    561                  * ```console
    562                  * $ node -e 'process.env.foo = "bar"' &#x26;&#x26; echo $foo
    563                  * ```
    564                  *
    565                  * While the following will:
    566                  *
    567                  * ```js
    568                  * import { env } from 'process';
    569                  *
    570                  * env.foo = 'bar';
    571                  * console.log(env.foo);
    572                  * ```
    573                  *
    574                  * Assigning a property on `process.env` will implicitly convert the value
    575                  * to a string. **This behavior is deprecated.** Future versions of Node.js may
    576                  * throw an error when the value is not a string, number, or boolean.
    577                  *
    578                  * ```js
    579                  * import { env } from 'process';
    580                  *
    581                  * env.test = null;
    582                  * console.log(env.test);
    583                  * // => 'null'
    584                  * env.test = undefined;
    585                  * console.log(env.test);
    586                  * // => 'undefined'
    587                  * ```
    588                  *
    589                  * Use `delete` to delete a property from `process.env`.
    590                  *
    591                  * ```js
    592                  * import { env } from 'process';
    593                  *
    594                  * env.TEST = 1;
    595                  * delete env.TEST;
    596                  * console.log(env.TEST);
    597                  * // => undefined
    598                  * ```
    599                  *
    600                  * On Windows operating systems, environment variables are case-insensitive.
    601                  *
    602                  * ```js
    603                  * import { env } from 'process';
    604                  *
    605                  * env.TEST = 1;
    606                  * console.log(env.test);
    607                  * // => 1
    608                  * ```
    609                  *
    610                  * Unless explicitly specified when creating a `Worker` instance,
    611                  * each `Worker` thread has its own copy of `process.env`, based on its
    612                  * parent thread’s `process.env`, or whatever was specified as the `env` option
    613                  * to the `Worker` constructor. Changes to `process.env` will not be visible
    614                  * across `Worker` threads, and only the main thread can make changes that
    615                  * are visible to the operating system or to native add-ons.
    616                  * @since v0.1.27
    617                  */
    618                 env: ProcessEnv;
    619                 /**
    620                  * The `process.exit()` method instructs Node.js to terminate the process
    621                  * synchronously with an exit status of `code`. If `code` is omitted, exit uses
    622                  * either the 'success' code `0` or the value of `process.exitCode` if it has been
    623                  * set. Node.js will not terminate until all the `'exit'` event listeners are
    624                  * called.
    625                  *
    626                  * To exit with a 'failure' code:
    627                  *
    628                  * ```js
    629                  * import { exit } from 'process';
    630                  *
    631                  * exit(1);
    632                  * ```
    633                  *
    634                  * The shell that executed Node.js should see the exit code as `1`.
    635                  *
    636                  * Calling `process.exit()` will force the process to exit as quickly as possible
    637                  * even if there are still asynchronous operations pending that have not yet
    638                  * completed fully, including I/O operations to `process.stdout` and `process.stderr`.
    639                  *
    640                  * In most situations, it is not actually necessary to call `process.exit()`explicitly. The Node.js process will exit on its own _if there is no additional_
    641                  * _work pending_ in the event loop. The `process.exitCode` property can be set to
    642                  * tell the process which exit code to use when the process exits gracefully.
    643                  *
    644                  * For instance, the following example illustrates a _misuse_ of the`process.exit()` method that could lead to data printed to stdout being
    645                  * truncated and lost:
    646                  *
    647                  * ```js
    648                  * import { exit } from 'process';
    649                  *
    650                  * // This is an example of what *not* to do:
    651                  * if (someConditionNotMet()) {
    652                  *   printUsageToStdout();
    653                  *   exit(1);
    654                  * }
    655                  * ```
    656                  *
    657                  * The reason this is problematic is because writes to `process.stdout` in Node.js
    658                  * are sometimes _asynchronous_ and may occur over multiple ticks of the Node.js
    659                  * event loop. Calling `process.exit()`, however, forces the process to exit_before_ those additional writes to `stdout` can be performed.
    660                  *
    661                  * Rather than calling `process.exit()` directly, the code _should_ set the`process.exitCode` and allow the process to exit naturally by avoiding
    662                  * scheduling any additional work for the event loop:
    663                  *
    664                  * ```js
    665                  * import process from 'process';
    666                  *
    667                  * // How to properly set the exit code while letting
    668                  * // the process exit gracefully.
    669                  * if (someConditionNotMet()) {
    670                  *   printUsageToStdout();
    671                  *   process.exitCode = 1;
    672                  * }
    673                  * ```
    674                  *
    675                  * If it is necessary to terminate the Node.js process due to an error condition,
    676                  * throwing an _uncaught_ error and allowing the process to terminate accordingly
    677                  * is safer than calling `process.exit()`.
    678                  *
    679                  * In `Worker` threads, this function stops the current thread rather
    680                  * than the current process.
    681                  * @since v0.1.13
    682                  * @param [code=0] The exit code.
    683                  */
    684                 exit(code?: number): never;
    685                 /**
    686                  * A number which will be the process exit code, when the process either
    687                  * exits gracefully, or is exited via {@link exit} without specifying
    688                  * a code.
    689                  *
    690                  * Specifying a code to {@link exit} will override any
    691                  * previous setting of `process.exitCode`.
    692                  * @since v0.11.8
    693                  */
    694                 exitCode?: number | undefined;
    695                 /**
    696                  * The `process.getgid()` method returns the numerical group identity of the
    697                  * process. (See [`getgid(2)`](http://man7.org/linux/man-pages/man2/getgid.2.html).)
    698                  *
    699                  * ```js
    700                  * import process from 'process';
    701                  *
    702                  * if (process.getgid) {
    703                  *   console.log(`Current gid: ${process.getgid()}`);
    704                  * }
    705                  * ```
    706                  *
    707                  * This function is only available on POSIX platforms (i.e. not Windows or
    708                  * Android).
    709                  * @since v0.1.31
    710                  */
    711                 getgid(): number;
    712                 /**
    713                  * The `process.setgid()` method sets the group identity of the process. (See [`setgid(2)`](http://man7.org/linux/man-pages/man2/setgid.2.html).) The `id` can be passed as either a
    714                  * numeric ID or a group name
    715                  * string. If a group name is specified, this method blocks while resolving the
    716                  * associated numeric ID.
    717                  *
    718                  * ```js
    719                  * import process from 'process';
    720                  *
    721                  * if (process.getgid &#x26;&#x26; process.setgid) {
    722                  *   console.log(`Current gid: ${process.getgid()}`);
    723                  *   try {
    724                  *     process.setgid(501);
    725                  *     console.log(`New gid: ${process.getgid()}`);
    726                  *   } catch (err) {
    727                  *     console.log(`Failed to set gid: ${err}`);
    728                  *   }
    729                  * }
    730                  * ```
    731                  *
    732                  * This function is only available on POSIX platforms (i.e. not Windows or
    733                  * Android).
    734                  * This feature is not available in `Worker` threads.
    735                  * @since v0.1.31
    736                  * @param id The group name or ID
    737                  */
    738                 setgid(id: number | string): void;
    739                 /**
    740                  * The `process.getuid()` method returns the numeric user identity of the process.
    741                  * (See [`getuid(2)`](http://man7.org/linux/man-pages/man2/getuid.2.html).)
    742                  *
    743                  * ```js
    744                  * import process from 'process';
    745                  *
    746                  * if (process.getuid) {
    747                  *   console.log(`Current uid: ${process.getuid()}`);
    748                  * }
    749                  * ```
    750                  *
    751                  * This function is only available on POSIX platforms (i.e. not Windows or
    752                  * Android).
    753                  * @since v0.1.28
    754                  */
    755                 getuid(): number;
    756                 /**
    757                  * The `process.setuid(id)` method sets the user identity of the process. (See [`setuid(2)`](http://man7.org/linux/man-pages/man2/setuid.2.html).) The `id` can be passed as either a
    758                  * numeric ID or a username string.
    759                  * If a username is specified, the method blocks while resolving the associated
    760                  * numeric ID.
    761                  *
    762                  * ```js
    763                  * import process from 'process';
    764                  *
    765                  * if (process.getuid &#x26;&#x26; process.setuid) {
    766                  *   console.log(`Current uid: ${process.getuid()}`);
    767                  *   try {
    768                  *     process.setuid(501);
    769                  *     console.log(`New uid: ${process.getuid()}`);
    770                  *   } catch (err) {
    771                  *     console.log(`Failed to set uid: ${err}`);
    772                  *   }
    773                  * }
    774                  * ```
    775                  *
    776                  * This function is only available on POSIX platforms (i.e. not Windows or
    777                  * Android).
    778                  * This feature is not available in `Worker` threads.
    779                  * @since v0.1.28
    780                  */
    781                 setuid(id: number | string): void;
    782                 /**
    783                  * The `process.geteuid()` method returns the numerical effective user identity of
    784                  * the process. (See [`geteuid(2)`](http://man7.org/linux/man-pages/man2/geteuid.2.html).)
    785                  *
    786                  * ```js
    787                  * import process from 'process';
    788                  *
    789                  * if (process.geteuid) {
    790                  *   console.log(`Current uid: ${process.geteuid()}`);
    791                  * }
    792                  * ```
    793                  *
    794                  * This function is only available on POSIX platforms (i.e. not Windows or
    795                  * Android).
    796                  * @since v2.0.0
    797                  */
    798                 geteuid(): number;
    799                 /**
    800                  * The `process.seteuid()` method sets the effective user identity of the process.
    801                  * (See [`seteuid(2)`](http://man7.org/linux/man-pages/man2/seteuid.2.html).) The `id` can be passed as either a numeric ID or a username
    802                  * string. If a username is specified, the method blocks while resolving the
    803                  * associated numeric ID.
    804                  *
    805                  * ```js
    806                  * import process from 'process';
    807                  *
    808                  * if (process.geteuid &#x26;&#x26; process.seteuid) {
    809                  *   console.log(`Current uid: ${process.geteuid()}`);
    810                  *   try {
    811                  *     process.seteuid(501);
    812                  *     console.log(`New uid: ${process.geteuid()}`);
    813                  *   } catch (err) {
    814                  *     console.log(`Failed to set uid: ${err}`);
    815                  *   }
    816                  * }
    817                  * ```
    818                  *
    819                  * This function is only available on POSIX platforms (i.e. not Windows or
    820                  * Android).
    821                  * This feature is not available in `Worker` threads.
    822                  * @since v2.0.0
    823                  * @param id A user name or ID
    824                  */
    825                 seteuid(id: number | string): void;
    826                 /**
    827                  * The `process.getegid()` method returns the numerical effective group identity
    828                  * of the Node.js process. (See [`getegid(2)`](http://man7.org/linux/man-pages/man2/getegid.2.html).)
    829                  *
    830                  * ```js
    831                  * import process from 'process';
    832                  *
    833                  * if (process.getegid) {
    834                  *   console.log(`Current gid: ${process.getegid()}`);
    835                  * }
    836                  * ```
    837                  *
    838                  * This function is only available on POSIX platforms (i.e. not Windows or
    839                  * Android).
    840                  * @since v2.0.0
    841                  */
    842                 getegid(): number;
    843                 /**
    844                  * The `process.setegid()` method sets the effective group identity of the process.
    845                  * (See [`setegid(2)`](http://man7.org/linux/man-pages/man2/setegid.2.html).) The `id` can be passed as either a numeric ID or a group
    846                  * name string. If a group name is specified, this method blocks while resolving
    847                  * the associated a numeric ID.
    848                  *
    849                  * ```js
    850                  * import process from 'process';
    851                  *
    852                  * if (process.getegid &#x26;&#x26; process.setegid) {
    853                  *   console.log(`Current gid: ${process.getegid()}`);
    854                  *   try {
    855                  *     process.setegid(501);
    856                  *     console.log(`New gid: ${process.getegid()}`);
    857                  *   } catch (err) {
    858                  *     console.log(`Failed to set gid: ${err}`);
    859                  *   }
    860                  * }
    861                  * ```
    862                  *
    863                  * This function is only available on POSIX platforms (i.e. not Windows or
    864                  * Android).
    865                  * This feature is not available in `Worker` threads.
    866                  * @since v2.0.0
    867                  * @param id A group name or ID
    868                  */
    869                 setegid(id: number | string): void;
    870                 /**
    871                  * The `process.getgroups()` method returns an array with the supplementary group
    872                  * IDs. POSIX leaves it unspecified if the effective group ID is included but
    873                  * Node.js ensures it always is.
    874                  *
    875                  * ```js
    876                  * import process from 'process';
    877                  *
    878                  * if (process.getgroups) {
    879                  *   console.log(process.getgroups()); // [ 16, 21, 297 ]
    880                  * }
    881                  * ```
    882                  *
    883                  * This function is only available on POSIX platforms (i.e. not Windows or
    884                  * Android).
    885                  * @since v0.9.4
    886                  */
    887                 getgroups(): number[];
    888                 /**
    889                  * The `process.setgroups()` method sets the supplementary group IDs for the
    890                  * Node.js process. This is a privileged operation that requires the Node.js
    891                  * process to have `root` or the `CAP_SETGID` capability.
    892                  *
    893                  * The `groups` array can contain numeric group IDs, group names, or both.
    894                  *
    895                  * ```js
    896                  * import process from 'process';
    897                  *
    898                  * if (process.getgroups &#x26;&#x26; process.setgroups) {
    899                  *   try {
    900                  *     process.setgroups([501]);
    901                  *     console.log(process.getgroups()); // new groups
    902                  *   } catch (err) {
    903                  *     console.log(`Failed to set groups: ${err}`);
    904                  *   }
    905                  * }
    906                  * ```
    907                  *
    908                  * This function is only available on POSIX platforms (i.e. not Windows or
    909                  * Android).
    910                  * This feature is not available in `Worker` threads.
    911                  * @since v0.9.4
    912                  */
    913                 setgroups(groups: ReadonlyArray<string | number>): void;
    914                 /**
    915                  * The `process.setUncaughtExceptionCaptureCallback()` function sets a function
    916                  * that will be invoked when an uncaught exception occurs, which will receive the
    917                  * exception value itself as its first argument.
    918                  *
    919                  * If such a function is set, the `'uncaughtException'` event will
    920                  * not be emitted. If `--abort-on-uncaught-exception` was passed from the
    921                  * command line or set through `v8.setFlagsFromString()`, the process will
    922                  * not abort. Actions configured to take place on exceptions such as report
    923                  * generations will be affected too
    924                  *
    925                  * To unset the capture function,`process.setUncaughtExceptionCaptureCallback(null)` may be used. Calling this
    926                  * method with a non-`null` argument while another capture function is set will
    927                  * throw an error.
    928                  *
    929                  * Using this function is mutually exclusive with using the deprecated `domain` built-in module.
    930                  * @since v9.3.0
    931                  */
    932                 setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
    933                 /**
    934                  * Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}.
    935                  * @since v9.3.0
    936                  */
    937                 hasUncaughtExceptionCaptureCallback(): boolean;
    938                 /**
    939                  * This function enables or disables the Source Map v3 support for stack traces.
    940                  * It provides same features as launching Node.js process with commandline options --enable-source-maps.
    941                  * @since v16.6.0
    942                  * @experimental
    943                  */
    944                 setSourceMapsEnabled(value: boolean): void;
    945                 /**
    946                  * The `process.version` property contains the Node.js version string.
    947                  *
    948                  * ```js
    949                  * import { version } from 'process';
    950                  *
    951                  * console.log(`Version: ${version}`);
    952                  * // Version: v14.8.0
    953                  * ```
    954                  *
    955                  * To get the version string without the prepended _v_, use`process.versions.node`.
    956                  * @since v0.1.3
    957                  */
    958                 readonly version: string;
    959                 /**
    960                  * The `process.versions` property returns an object listing the version strings of
    961                  * Node.js and its dependencies. `process.versions.modules` indicates the current
    962                  * ABI version, which is increased whenever a C++ API changes. Node.js will refuse
    963                  * to load modules that were compiled against a different module ABI version.
    964                  *
    965                  * ```js
    966                  * import { versions } from 'process';
    967                  *
    968                  * console.log(versions);
    969                  * ```
    970                  *
    971                  * Will generate an object similar to:
    972                  *
    973                  * ```console
    974                  * { node: '11.13.0',
    975                  *   v8: '7.0.276.38-node.18',
    976                  *   uv: '1.27.0',
    977                  *   zlib: '1.2.11',
    978                  *   brotli: '1.0.7',
    979                  *   ares: '1.15.0',
    980                  *   modules: '67',
    981                  *   nghttp2: '1.34.0',
    982                  *   napi: '4',
    983                  *   llhttp: '1.1.1',
    984                  *   openssl: '1.1.1b',
    985                  *   cldr: '34.0',
    986                  *   icu: '63.1',
    987                  *   tz: '2018e',
    988                  *   unicode: '11.0' }
    989                  * ```
    990                  * @since v0.2.0
    991                  */
    992                 readonly versions: ProcessVersions;
    993                 /**
    994                  * The `process.config` property returns an `Object` containing the JavaScript
    995                  * representation of the configure options used to compile the current Node.js
    996                  * executable. This is the same as the `config.gypi` file that was produced when
    997                  * running the `./configure` script.
    998                  *
    999                  * An example of the possible output looks like:
   1000                  *
   1001                  * ```js
   1002                  * {
   1003                  *   target_defaults:
   1004                  *    { cflags: [],
   1005                  *      default_configuration: 'Release',
   1006                  *      defines: [],
   1007                  *      include_dirs: [],
   1008                  *      libraries: [] },
   1009                  *   variables:
   1010                  *    {
   1011                  *      host_arch: 'x64',
   1012                  *      napi_build_version: 5,
   1013                  *      node_install_npm: 'true',
   1014                  *      node_prefix: '',
   1015                  *      node_shared_cares: 'false',
   1016                  *      node_shared_http_parser: 'false',
   1017                  *      node_shared_libuv: 'false',
   1018                  *      node_shared_zlib: 'false',
   1019                  *      node_use_dtrace: 'false',
   1020                  *      node_use_openssl: 'true',
   1021                  *      node_shared_openssl: 'false',
   1022                  *      strict_aliasing: 'true',
   1023                  *      target_arch: 'x64',
   1024                  *      v8_use_snapshot: 1
   1025                  *    }
   1026                  * }
   1027                  * ```
   1028                  *
   1029                  * The `process.config` property is **not** read-only and there are existing
   1030                  * modules in the ecosystem that are known to extend, modify, or entirely replace
   1031                  * the value of `process.config`.
   1032                  *
   1033                  * Modifying the `process.config` property, or any child-property of the`process.config` object has been deprecated. The `process.config` will be made
   1034                  * read-only in a future release.
   1035                  * @since v0.7.7
   1036                  */
   1037                 readonly config: ProcessConfig;
   1038                 /**
   1039                  * The `process.kill()` method sends the `signal` to the process identified by`pid`.
   1040                  *
   1041                  * Signal names are strings such as `'SIGINT'` or `'SIGHUP'`. See `Signal Events` and [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for more information.
   1042                  *
   1043                  * This method will throw an error if the target `pid` does not exist. As a special
   1044                  * case, a signal of `0` can be used to test for the existence of a process.
   1045                  * Windows platforms will throw an error if the `pid` is used to kill a process
   1046                  * group.
   1047                  *
   1048                  * Even though the name of this function is `process.kill()`, it is really just a
   1049                  * signal sender, like the `kill` system call. The signal sent may do something
   1050                  * other than kill the target process.
   1051                  *
   1052                  * ```js
   1053                  * import process, { kill } from 'process';
   1054                  *
   1055                  * process.on('SIGHUP', () => {
   1056                  *   console.log('Got SIGHUP signal.');
   1057                  * });
   1058                  *
   1059                  * setTimeout(() => {
   1060                  *   console.log('Exiting.');
   1061                  *   process.exit(0);
   1062                  * }, 100);
   1063                  *
   1064                  * kill(process.pid, 'SIGHUP');
   1065                  * ```
   1066                  *
   1067                  * When `SIGUSR1` is received by a Node.js process, Node.js will start the
   1068                  * debugger. See `Signal Events`.
   1069                  * @since v0.0.6
   1070                  * @param pid A process ID
   1071                  * @param [signal='SIGTERM'] The signal to send, either as a string or number.
   1072                  */
   1073                 kill(pid: number, signal?: string | number): true;
   1074                 /**
   1075                  * The `process.pid` property returns the PID of the process.
   1076                  *
   1077                  * ```js
   1078                  * import { pid } from 'process';
   1079                  *
   1080                  * console.log(`This process is pid ${pid}`);
   1081                  * ```
   1082                  * @since v0.1.15
   1083                  */
   1084                 readonly pid: number;
   1085                 /**
   1086                  * The `process.ppid` property returns the PID of the parent of the
   1087                  * current process.
   1088                  *
   1089                  * ```js
   1090                  * import { ppid } from 'process';
   1091                  *
   1092                  * console.log(`The parent process is pid ${ppid}`);
   1093                  * ```
   1094                  * @since v9.2.0, v8.10.0, v6.13.0
   1095                  */
   1096                 readonly ppid: number;
   1097                 /**
   1098                  * The `process.title` property returns the current process title (i.e. returns
   1099                  * the current value of `ps`). Assigning a new value to `process.title` modifies
   1100                  * the current value of `ps`.
   1101                  *
   1102                  * When a new value is assigned, different platforms will impose different maximum
   1103                  * length restrictions on the title. Usually such restrictions are quite limited.
   1104                  * For instance, on Linux and macOS, `process.title` is limited to the size of the
   1105                  * binary name plus the length of the command-line arguments because setting the`process.title` overwrites the `argv` memory of the process. Node.js v0.8
   1106                  * allowed for longer process title strings by also overwriting the `environ`memory but that was potentially insecure and confusing in some (rather obscure)
   1107                  * cases.
   1108                  *
   1109                  * Assigning a value to `process.title` might not result in an accurate label
   1110                  * within process manager applications such as macOS Activity Monitor or Windows
   1111                  * Services Manager.
   1112                  * @since v0.1.104
   1113                  */
   1114                 title: string;
   1115                 /**
   1116                  * The operating system CPU architecture for which the Node.js binary was compiled.
   1117                  * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
   1118                  *
   1119                  * ```js
   1120                  * import { arch } from 'process';
   1121                  *
   1122                  * console.log(`This processor architecture is ${arch}`);
   1123                  * ```
   1124                  * @since v0.5.0
   1125                  */
   1126                 readonly arch: string;
   1127                 /**
   1128                  * The `process.platform` property returns a string identifying the operating
   1129                  * system platform on which the Node.js process is running.
   1130                  *
   1131                  * Currently possible values are:
   1132                  *
   1133                  * * `'aix'`
   1134                  * * `'darwin'`
   1135                  * * `'freebsd'`
   1136                  * * `'linux'`
   1137                  * * `'openbsd'`
   1138                  * * `'sunos'`
   1139                  * * `'win32'`
   1140                  *
   1141                  * ```js
   1142                  * import { platform } from 'process';
   1143                  *
   1144                  * console.log(`This platform is ${platform}`);
   1145                  * ```
   1146                  *
   1147                  * The value `'android'` may also be returned if the Node.js is built on the
   1148                  * Android operating system. However, Android support in Node.js [is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
   1149                  * @since v0.1.16
   1150                  */
   1151                 readonly platform: Platform;
   1152                 /**
   1153                  * The `process.mainModule` property provides an alternative way of retrieving `require.main`. The difference is that if the main module changes at
   1154                  * runtime, `require.main` may still refer to the original main module in
   1155                  * modules that were required before the change occurred. Generally, it's
   1156                  * safe to assume that the two refer to the same module.
   1157                  *
   1158                  * As with `require.main`, `process.mainModule` will be `undefined` if there
   1159                  * is no entry script.
   1160                  * @since v0.1.17
   1161                  * @deprecated Since v14.0.0 - Use `main` instead.
   1162                  */
   1163                 mainModule?: Module | undefined;
   1164                 memoryUsage: MemoryUsageFn;
   1165                 /**
   1166                  * The `process.cpuUsage()` method returns the user and system CPU time usage of
   1167                  * the current process, in an object with properties `user` and `system`, whose
   1168                  * values are microsecond values (millionth of a second). These values measure time
   1169                  * spent in user and system code respectively, and may end up being greater than
   1170                  * actual elapsed time if multiple CPU cores are performing work for this process.
   1171                  *
   1172                  * The result of a previous call to `process.cpuUsage()` can be passed as the
   1173                  * argument to the function, to get a diff reading.
   1174                  *
   1175                  * ```js
   1176                  * import { cpuUsage } from 'process';
   1177                  *
   1178                  * const startUsage = cpuUsage();
   1179                  * // { user: 38579, system: 6986 }
   1180                  *
   1181                  * // spin the CPU for 500 milliseconds
   1182                  * const now = Date.now();
   1183                  * while (Date.now() - now < 500);
   1184                  *
   1185                  * console.log(cpuUsage(startUsage));
   1186                  * // { user: 514883, system: 11226 }
   1187                  * ```
   1188                  * @since v6.1.0
   1189                  * @param previousValue A previous return value from calling `process.cpuUsage()`
   1190                  */
   1191                 cpuUsage(previousValue?: CpuUsage): CpuUsage;
   1192                 /**
   1193                  * `process.nextTick()` adds `callback` to the "next tick queue". This queue is
   1194                  * fully drained after the current operation on the JavaScript stack runs to
   1195                  * completion and before the event loop is allowed to continue. It's possible to
   1196                  * create an infinite loop if one were to recursively call `process.nextTick()`.
   1197                  * See the [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick) guide for more background.
   1198                  *
   1199                  * ```js
   1200                  * import { nextTick } from 'process';
   1201                  *
   1202                  * console.log('start');
   1203                  * nextTick(() => {
   1204                  *   console.log('nextTick callback');
   1205                  * });
   1206                  * console.log('scheduled');
   1207                  * // Output:
   1208                  * // start
   1209                  * // scheduled
   1210                  * // nextTick callback
   1211                  * ```
   1212                  *
   1213                  * This is important when developing APIs in order to give users the opportunity
   1214                  * to assign event handlers _after_ an object has been constructed but before any
   1215                  * I/O has occurred:
   1216                  *
   1217                  * ```js
   1218                  * import { nextTick } from 'process';
   1219                  *
   1220                  * function MyThing(options) {
   1221                  *   this.setupOptions(options);
   1222                  *
   1223                  *   nextTick(() => {
   1224                  *     this.startDoingStuff();
   1225                  *   });
   1226                  * }
   1227                  *
   1228                  * const thing = new MyThing();
   1229                  * thing.getReadyForStuff();
   1230                  *
   1231                  * // thing.startDoingStuff() gets called now, not before.
   1232                  * ```
   1233                  *
   1234                  * It is very important for APIs to be either 100% synchronous or 100%
   1235                  * asynchronous. Consider this example:
   1236                  *
   1237                  * ```js
   1238                  * // WARNING!  DO NOT USE!  BAD UNSAFE HAZARD!
   1239                  * function maybeSync(arg, cb) {
   1240                  *   if (arg) {
   1241                  *     cb();
   1242                  *     return;
   1243                  *   }
   1244                  *
   1245                  *   fs.stat('file', cb);
   1246                  * }
   1247                  * ```
   1248                  *
   1249                  * This API is hazardous because in the following case:
   1250                  *
   1251                  * ```js
   1252                  * const maybeTrue = Math.random() > 0.5;
   1253                  *
   1254                  * maybeSync(maybeTrue, () => {
   1255                  *   foo();
   1256                  * });
   1257                  *
   1258                  * bar();
   1259                  * ```
   1260                  *
   1261                  * It is not clear whether `foo()` or `bar()` will be called first.
   1262                  *
   1263                  * The following approach is much better:
   1264                  *
   1265                  * ```js
   1266                  * import { nextTick } from 'process';
   1267                  *
   1268                  * function definitelyAsync(arg, cb) {
   1269                  *   if (arg) {
   1270                  *     nextTick(cb);
   1271                  *     return;
   1272                  *   }
   1273                  *
   1274                  *   fs.stat('file', cb);
   1275                  * }
   1276                  * ```
   1277                  * @since v0.1.26
   1278                  * @param args Additional arguments to pass when invoking the `callback`
   1279                  */
   1280                 nextTick(callback: Function, ...args: any[]): void;
   1281                 /**
   1282                  * The `process.release` property returns an `Object` containing metadata related
   1283                  * to the current release, including URLs for the source tarball and headers-only
   1284                  * tarball.
   1285                  *
   1286                  * `process.release` contains the following properties:
   1287                  *
   1288                  * ```js
   1289                  * {
   1290                  *   name: 'node',
   1291                  *   lts: 'Erbium',
   1292                  *   sourceUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1.tar.gz',
   1293                  *   headersUrl: 'https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz',
   1294                  *   libUrl: 'https://nodejs.org/download/release/v12.18.1/win-x64/node.lib'
   1295                  * }
   1296                  * ```
   1297                  *
   1298                  * In custom builds from non-release versions of the source tree, only the`name` property may be present. The additional properties should not be
   1299                  * relied upon to exist.
   1300                  * @since v3.0.0
   1301                  */
   1302                 readonly release: ProcessRelease;
   1303                 features: {
   1304                     inspector: boolean;
   1305                     debug: boolean;
   1306                     uv: boolean;
   1307                     ipv6: boolean;
   1308                     tls_alpn: boolean;
   1309                     tls_sni: boolean;
   1310                     tls_ocsp: boolean;
   1311                     tls: boolean;
   1312                 };
   1313                 /**
   1314                  * `process.umask()` returns the Node.js process's file mode creation mask. Child
   1315                  * processes inherit the mask from the parent process.
   1316                  * @since v0.1.19
   1317                  * @deprecated Calling `process.umask()` with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential   *
   1318                  * security vulnerability. There is no safe, cross-platform alternative API.
   1319                  */
   1320                 umask(): number;
   1321                 /**
   1322                  * Can only be set if not in worker thread.
   1323                  */
   1324                 umask(mask: string | number): number;
   1325                 /**
   1326                  * The `process.uptime()` method returns the number of seconds the current Node.js
   1327                  * process has been running.
   1328                  *
   1329                  * The return value includes fractions of a second. Use `Math.floor()` to get whole
   1330                  * seconds.
   1331                  * @since v0.5.0
   1332                  */
   1333                 uptime(): number;
   1334                 hrtime: HRTime;
   1335                 /**
   1336                  * If the Node.js process was spawned with an IPC channel, the process.channel property is a reference to the IPC channel.
   1337                  * If no IPC channel exists, this property is undefined.
   1338                  * @since v7.1.0
   1339                  */
   1340                 channel?: {
   1341                     /**
   1342                      * This method makes the IPC channel keep the event loop of the process running if .unref() has been called before.
   1343                      * @since v7.1.0
   1344                      */
   1345                     ref(): void;
   1346                     /**
   1347                      * This method makes the IPC channel not keep the event loop of the process running, and lets it finish even while the channel is open.
   1348                      * @since v7.1.0
   1349                      */
   1350                     unref(): void;
   1351                 };
   1352                 /**
   1353                  * If Node.js is spawned with an IPC channel, the `process.send()` method can be
   1354                  * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object.
   1355                  *
   1356                  * If Node.js was not spawned with an IPC channel, `process.send` will be `undefined`.
   1357                  *
   1358                  * The message goes through serialization and parsing. The resulting message might
   1359                  * not be the same as what is originally sent.
   1360                  * @since v0.5.9
   1361                  * @param options used to parameterize the sending of certain types of handles.`options` supports the following properties:
   1362                  */
   1363                 send?(
   1364                     message: any,
   1365                     sendHandle?: any,
   1366                     options?: {
   1367                         swallowErrors?: boolean | undefined;
   1368                     },
   1369                     callback?: (error: Error | null) => void,
   1370                 ): boolean;
   1371                 /**
   1372                  * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.disconnect()` method will close the
   1373                  * IPC channel to the parent process, allowing the child process to exit gracefully
   1374                  * once there are no other connections keeping it alive.
   1375                  *
   1376                  * The effect of calling `process.disconnect()` is the same as calling `ChildProcess.disconnect()` from the parent process.
   1377                  *
   1378                  * If the Node.js process was not spawned with an IPC channel,`process.disconnect()` will be `undefined`.
   1379                  * @since v0.7.2
   1380                  */
   1381                 disconnect(): void;
   1382                 /**
   1383                  * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.connected` property will return`true` so long as the IPC
   1384                  * channel is connected and will return `false` after`process.disconnect()` is called.
   1385                  *
   1386                  * Once `process.connected` is `false`, it is no longer possible to send messages
   1387                  * over the IPC channel using `process.send()`.
   1388                  * @since v0.7.2
   1389                  */
   1390                 connected: boolean;
   1391                 /**
   1392                  * The `process.allowedNodeEnvironmentFlags` property is a special,
   1393                  * read-only `Set` of flags allowable within the `NODE_OPTIONS` environment variable.
   1394                  *
   1395                  * `process.allowedNodeEnvironmentFlags` extends `Set`, but overrides`Set.prototype.has` to recognize several different possible flag
   1396                  * representations. `process.allowedNodeEnvironmentFlags.has()` will
   1397                  * return `true` in the following cases:
   1398                  *
   1399                  * * Flags may omit leading single (`-`) or double (`--`) dashes; e.g.,`inspect-brk` for `--inspect-brk`, or `r` for `-r`.
   1400                  * * Flags passed through to V8 (as listed in `--v8-options`) may replace
   1401                  * one or more _non-leading_ dashes for an underscore, or vice-versa;
   1402                  * e.g., `--perf_basic_prof`, `--perf-basic-prof`, `--perf_basic-prof`,
   1403                  * etc.
   1404                  * * Flags may contain one or more equals (`=`) characters; all
   1405                  * characters after and including the first equals will be ignored;
   1406                  * e.g., `--stack-trace-limit=100`.
   1407                  * * Flags _must_ be allowable within `NODE_OPTIONS`.
   1408                  *
   1409                  * When iterating over `process.allowedNodeEnvironmentFlags`, flags will
   1410                  * appear only _once_; each will begin with one or more dashes. Flags
   1411                  * passed through to V8 will contain underscores instead of non-leading
   1412                  * dashes:
   1413                  *
   1414                  * ```js
   1415                  * import { allowedNodeEnvironmentFlags } from 'process';
   1416                  *
   1417                  * allowedNodeEnvironmentFlags.forEach((flag) => {
   1418                  *   // -r
   1419                  *   // --inspect-brk
   1420                  *   // --abort_on_uncaught_exception
   1421                  *   // ...
   1422                  * });
   1423                  * ```
   1424                  *
   1425                  * The methods `add()`, `clear()`, and `delete()` of`process.allowedNodeEnvironmentFlags` do nothing, and will fail
   1426                  * silently.
   1427                  *
   1428                  * If Node.js was compiled _without_ `NODE_OPTIONS` support (shown in {@link config}), `process.allowedNodeEnvironmentFlags` will
   1429                  * contain what _would have_ been allowable.
   1430                  * @since v10.10.0
   1431                  */
   1432                 allowedNodeEnvironmentFlags: ReadonlySet<string>;
   1433                 /**
   1434                  * `process.report` is an object whose methods are used to generate diagnostic
   1435                  * reports for the current process. Additional documentation is available in the `report documentation`.
   1436                  * @since v11.8.0
   1437                  */
   1438                 report?: ProcessReport | undefined;
   1439                 /**
   1440                  * ```js
   1441                  * import { resourceUsage } from 'process';
   1442                  *
   1443                  * console.log(resourceUsage());
   1444                  * /*
   1445                  *   Will output:
   1446                  *   {
   1447                  *     userCPUTime: 82872,
   1448                  *     systemCPUTime: 4143,
   1449                  *     maxRSS: 33164,
   1450                  *     sharedMemorySize: 0,
   1451                  *     unsharedDataSize: 0,
   1452                  *     unsharedStackSize: 0,
   1453                  *     minorPageFault: 2469,
   1454                  *     majorPageFault: 0,
   1455                  *     swappedOut: 0,
   1456                  *     fsRead: 0,
   1457                  *     fsWrite: 8,
   1458                  *     ipcSent: 0,
   1459                  *     ipcReceived: 0,
   1460                  *     signalsCount: 0,
   1461                  *     voluntaryContextSwitches: 79,
   1462                  *     involuntaryContextSwitches: 1
   1463                  *   }
   1464                  *
   1465                  * ```
   1466                  * @since v12.6.0
   1467                  * @return the resource usage for the current process. All of these values come from the `uv_getrusage` call which returns a [`uv_rusage_t` struct][uv_rusage_t].
   1468                  */
   1469                 resourceUsage(): ResourceUsage;
   1470                 /**
   1471                  * The `process.traceDeprecation` property indicates whether the`--trace-deprecation` flag is set on the current Node.js process. See the
   1472                  * documentation for the `'warning' event` and the `emitWarning() method` for more information about this
   1473                  * flag's behavior.
   1474                  * @since v0.8.0
   1475                  */
   1476                 traceDeprecation: boolean;
   1477                 /* EventEmitter */
   1478                 addListener(event: "beforeExit", listener: BeforeExitListener): this;
   1479                 addListener(event: "disconnect", listener: DisconnectListener): this;
   1480                 addListener(event: "exit", listener: ExitListener): this;
   1481                 addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
   1482                 addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
   1483                 addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
   1484                 addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
   1485                 addListener(event: "warning", listener: WarningListener): this;
   1486                 addListener(event: "message", listener: MessageListener): this;
   1487                 addListener(event: Signals, listener: SignalsListener): this;
   1488                 addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
   1489                 addListener(event: "worker", listener: WorkerListener): this;
   1490                 emit(event: "beforeExit", code: number): boolean;
   1491                 emit(event: "disconnect"): boolean;
   1492                 emit(event: "exit", code: number): boolean;
   1493                 emit(event: "rejectionHandled", promise: Promise<unknown>): boolean;
   1494                 emit(event: "uncaughtException", error: Error): boolean;
   1495                 emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
   1496                 emit(event: "unhandledRejection", reason: unknown, promise: Promise<unknown>): boolean;
   1497                 emit(event: "warning", warning: Error): boolean;
   1498                 emit(event: "message", message: unknown, sendHandle: unknown): this;
   1499                 emit(event: Signals, signal: Signals): boolean;
   1500                 emit(
   1501                     event: "multipleResolves",
   1502                     type: MultipleResolveType,
   1503                     promise: Promise<unknown>,
   1504                     value: unknown,
   1505                 ): this;
   1506                 emit(event: "worker", listener: WorkerListener): this;
   1507                 on(event: "beforeExit", listener: BeforeExitListener): this;
   1508                 on(event: "disconnect", listener: DisconnectListener): this;
   1509                 on(event: "exit", listener: ExitListener): this;
   1510                 on(event: "rejectionHandled", listener: RejectionHandledListener): this;
   1511                 on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
   1512                 on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
   1513                 on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
   1514                 on(event: "warning", listener: WarningListener): this;
   1515                 on(event: "message", listener: MessageListener): this;
   1516                 on(event: Signals, listener: SignalsListener): this;
   1517                 on(event: "multipleResolves", listener: MultipleResolveListener): this;
   1518                 on(event: "worker", listener: WorkerListener): this;
   1519                 on(event: string | symbol, listener: (...args: any[]) => void): this;
   1520                 once(event: "beforeExit", listener: BeforeExitListener): this;
   1521                 once(event: "disconnect", listener: DisconnectListener): this;
   1522                 once(event: "exit", listener: ExitListener): this;
   1523                 once(event: "rejectionHandled", listener: RejectionHandledListener): this;
   1524                 once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
   1525                 once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
   1526                 once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
   1527                 once(event: "warning", listener: WarningListener): this;
   1528                 once(event: "message", listener: MessageListener): this;
   1529                 once(event: Signals, listener: SignalsListener): this;
   1530                 once(event: "multipleResolves", listener: MultipleResolveListener): this;
   1531                 once(event: "worker", listener: WorkerListener): this;
   1532                 once(event: string | symbol, listener: (...args: any[]) => void): this;
   1533                 prependListener(event: "beforeExit", listener: BeforeExitListener): this;
   1534                 prependListener(event: "disconnect", listener: DisconnectListener): this;
   1535                 prependListener(event: "exit", listener: ExitListener): this;
   1536                 prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
   1537                 prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
   1538                 prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
   1539                 prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
   1540                 prependListener(event: "warning", listener: WarningListener): this;
   1541                 prependListener(event: "message", listener: MessageListener): this;
   1542                 prependListener(event: Signals, listener: SignalsListener): this;
   1543                 prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
   1544                 prependListener(event: "worker", listener: WorkerListener): this;
   1545                 prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
   1546                 prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
   1547                 prependOnceListener(event: "exit", listener: ExitListener): this;
   1548                 prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
   1549                 prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
   1550                 prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
   1551                 prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
   1552                 prependOnceListener(event: "warning", listener: WarningListener): this;
   1553                 prependOnceListener(event: "message", listener: MessageListener): this;
   1554                 prependOnceListener(event: Signals, listener: SignalsListener): this;
   1555                 prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
   1556                 prependOnceListener(event: "worker", listener: WorkerListener): this;
   1557                 listeners(event: "beforeExit"): BeforeExitListener[];
   1558                 listeners(event: "disconnect"): DisconnectListener[];
   1559                 listeners(event: "exit"): ExitListener[];
   1560                 listeners(event: "rejectionHandled"): RejectionHandledListener[];
   1561                 listeners(event: "uncaughtException"): UncaughtExceptionListener[];
   1562                 listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
   1563                 listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
   1564                 listeners(event: "warning"): WarningListener[];
   1565                 listeners(event: "message"): MessageListener[];
   1566                 listeners(event: Signals): SignalsListener[];
   1567                 listeners(event: "multipleResolves"): MultipleResolveListener[];
   1568                 listeners(event: "worker"): WorkerListener[];
   1569             }
   1570         }
   1571     }
   1572     export = process;
   1573 }
   1574 declare module "node:process" {
   1575     import process = require("process");
   1576     export = process;
   1577 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror