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