UNPKG

27.8 kBTypeScriptView Raw
1// Declare "static" methods in Error
2interface ErrorConstructor {
3 /** Create .stack property on a target object */
4 captureStackTrace(targetObject: object, constructorOpt?: Function): void;
5
6 /**
7 * Optional override for formatting stack traces
8 *
9 * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
10 */
11 prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
12
13 stackTraceLimit: number;
14}
15
16// Node.js ESNEXT support
17interface String {
18 /** Removes whitespace from the left end of a string. */
19 trimLeft(): string;
20 /** Removes whitespace from the right end of a string. */
21 trimRight(): string;
22
23 /** Returns a copy with leading whitespace removed. */
24 trimStart(): string;
25 /** Returns a copy with trailing whitespace removed. */
26 trimEnd(): string;
27}
28
29interface ImportMeta {
30 url: string;
31}
32
33/*-----------------------------------------------*
34 * *
35 * GLOBAL *
36 * *
37 ------------------------------------------------*/
38
39// For backwards compability
40interface NodeRequire extends NodeJS.Require {}
41interface RequireResolve extends NodeJS.RequireResolve {}
42interface NodeModule extends NodeJS.Module {}
43
44declare var process: NodeJS.Process;
45declare var console: Console;
46
47declare var __filename: string;
48declare var __dirname: string;
49
50declare function setTimeout(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
51declare namespace setTimeout {
52 function __promisify__(ms: number): Promise<void>;
53 function __promisify__<T>(ms: number, value: T): Promise<T>;
54}
55declare function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void;
56declare function setInterval(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
57declare function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void;
58declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
59declare namespace setImmediate {
60 function __promisify__(): Promise<void>;
61 function __promisify__<T>(value: T): Promise<T>;
62}
63declare function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
64
65declare function queueMicrotask(callback: () => void): void;
66
67declare var require: NodeRequire;
68declare var module: NodeModule;
69
70// Same as module.exports
71declare var exports: any;
72
73// Buffer class
74type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
75
76type WithImplicitCoercion<T> = T | { valueOf(): T };
77
78//#region borrowed
79// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
80/**
81 * A controller object that allows you to abort one or more DOM requests as and when desired.
82 * @since v14.7.0
83 */
84interface AbortController {
85 /**
86 * Returns the AbortSignal object associated with this object.
87 * @since v14.7.0
88 */
89 readonly signal: AbortSignal;
90 /**
91 * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
92 * @since v14.7.0
93 */
94 abort(): void;
95}
96
97/**
98 * A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object.
99 * @since v14.7.0
100 */
101interface AbortSignal {
102 /**
103 * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
104 * @since v14.7.0
105 */
106 readonly aborted: boolean;
107}
108
109declare var AbortController: {
110 prototype: AbortController;
111 new(): AbortController;
112};
113
114declare var AbortSignal: {
115 prototype: AbortSignal;
116 new(): AbortSignal;
117 abort(reason?: any): AbortSignal;
118 timeout(milliseconds: number): AbortSignal;
119};
120//#endregion borrowed
121
122/**
123 * Raw data is stored in instances of the Buffer class.
124 * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
125 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
126 */
127declare class Buffer extends Uint8Array {
128 /**
129 * Allocates a new buffer containing the given {str}.
130 *
131 * @param str String to store in buffer.
132 * @param encoding encoding to use, optional. Default is 'utf8'
133 * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
134 */
135 constructor(str: string, encoding?: BufferEncoding);
136 /**
137 * Allocates a new buffer of {size} octets.
138 *
139 * @param size count of octets to allocate.
140 * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
141 */
142 constructor(size: number);
143 /**
144 * Allocates a new buffer containing the given {array} of octets.
145 *
146 * @param array The octets to store.
147 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
148 */
149 constructor(array: Uint8Array);
150 /**
151 * Produces a Buffer backed by the same allocated memory as
152 * the given {ArrayBuffer}/{SharedArrayBuffer}.
153 *
154 *
155 * @param arrayBuffer The ArrayBuffer with which to share memory.
156 * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
157 */
158 constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
159 /**
160 * Allocates a new buffer containing the given {array} of octets.
161 *
162 * @param array The octets to store.
163 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
164 */
165 constructor(array: ReadonlyArray<any>);
166 /**
167 * Copies the passed {buffer} data onto a new {Buffer} instance.
168 *
169 * @param buffer The buffer to copy.
170 * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
171 */
172 constructor(buffer: Buffer);
173 /**
174 * When passed a reference to the .buffer property of a TypedArray instance,
175 * the newly created Buffer will share the same allocated memory as the TypedArray.
176 * The optional {byteOffset} and {length} arguments specify a memory range
177 * within the {arrayBuffer} that will be shared by the Buffer.
178 *
179 * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
180 */
181 static from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
182 /**
183 * Creates a new Buffer using the passed {data}
184 * @param data data to create a new Buffer
185 */
186 static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
187 static from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
188 /**
189 * Creates a new Buffer containing the given JavaScript string {str}.
190 * If provided, the {encoding} parameter identifies the character encoding.
191 * If not provided, {encoding} defaults to 'utf8'.
192 */
193 static from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
194 /**
195 * Creates a new Buffer using the passed {data}
196 * @param values to create a new Buffer
197 */
198 static of(...items: number[]): Buffer;
199 /**
200 * Returns true if {obj} is a Buffer
201 *
202 * @param obj object to test.
203 */
204 static isBuffer(obj: any): obj is Buffer;
205 /**
206 * Returns true if {encoding} is a valid encoding argument.
207 * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
208 *
209 * @param encoding string to test.
210 */
211 static isEncoding(encoding: string): encoding is BufferEncoding;
212 /**
213 * Gives the actual byte length of a string. encoding defaults to 'utf8'.
214 * This is not the same as String.prototype.length since that returns the number of characters in a string.
215 *
216 * @param string string to test.
217 * @param encoding encoding used to evaluate (defaults to 'utf8')
218 */
219 static byteLength(
220 string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
221 encoding?: BufferEncoding
222 ): number;
223 /**
224 * Returns a buffer which is the result of concatenating all the buffers in the list together.
225 *
226 * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
227 * If the list has exactly one item, then the first item of the list is returned.
228 * If the list has more than one item, then a new Buffer is created.
229 *
230 * @param list An array of Buffer objects to concatenate
231 * @param totalLength Total length of the buffers when concatenated.
232 * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
233 */
234 static concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
235 /**
236 * The same as buf1.compare(buf2).
237 */
238 static compare(buf1: Uint8Array, buf2: Uint8Array): number;
239 /**
240 * Allocates a new buffer of {size} octets.
241 *
242 * @param size count of octets to allocate.
243 * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
244 * If parameter is omitted, buffer will be filled with zeros.
245 * @param encoding encoding used for call to buf.fill while initalizing
246 */
247 static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
248 /**
249 * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
250 * of the newly created Buffer are unknown and may contain sensitive data.
251 *
252 * @param size count of octets to allocate
253 */
254 static allocUnsafe(size: number): Buffer;
255 /**
256 * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
257 * of the newly created Buffer are unknown and may contain sensitive data.
258 *
259 * @param size count of octets to allocate
260 */
261 static allocUnsafeSlow(size: number): Buffer;
262 /**
263 * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
264 */
265 static poolSize: number;
266
267 write(string: string, encoding?: BufferEncoding): number;
268 write(string: string, offset: number, encoding?: BufferEncoding): number;
269 write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
270 toString(encoding?: BufferEncoding, start?: number, end?: number): string;
271 toJSON(): { type: 'Buffer'; data: number[] };
272 equals(otherBuffer: Uint8Array): boolean;
273 compare(
274 otherBuffer: Uint8Array,
275 targetStart?: number,
276 targetEnd?: number,
277 sourceStart?: number,
278 sourceEnd?: number
279 ): number;
280 copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
281 /**
282 * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
283 *
284 * This method is incompatible with `Uint8Array#slice()`, which returns a copy of the original memory.
285 *
286 * @param begin Where the new `Buffer` will start. Default: `0`.
287 * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
288 */
289 slice(begin?: number, end?: number): Buffer;
290 /**
291 * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
292 *
293 * This method is compatible with `Uint8Array#subarray()`.
294 *
295 * @param begin Where the new `Buffer` will start. Default: `0`.
296 * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
297 */
298 subarray(begin?: number, end?: number): Buffer;
299 writeBigInt64BE(value: bigint, offset?: number): number;
300 writeBigInt64LE(value: bigint, offset?: number): number;
301 writeBigUInt64BE(value: bigint, offset?: number): number;
302 /**
303 * @alias Buffer.writeBigUInt64BE
304 * @since v14.10.0, v12.19.0
305 */
306 writeBigUint64BE(value: bigint, offset?: number): number;
307 writeBigUInt64LE(value: bigint, offset?: number): number;
308 /**
309 * @alias Buffer.writeBigUInt64LE
310 * @since v14.10.0, v12.19.0
311 */
312 writeBigUint64LE(value: bigint, offset?: number): number;
313 writeUIntLE(value: number, offset: number, byteLength: number): number;
314 /**
315 * @alias Buffer.writeUIntLE
316 * @since v14.9.0, v12.19.0
317 */
318 writeUintLE(value: number, offset: number, byteLength: number): number;
319 writeUIntBE(value: number, offset: number, byteLength: number): number;
320 /**
321 * @alias Buffer.writeUIntBE
322 * @since v14.9.0, v12.19.0
323 */
324 writeUintBE(value: number, offset: number, byteLength: number): number;
325 writeIntLE(value: number, offset: number, byteLength: number): number;
326 writeIntBE(value: number, offset: number, byteLength: number): number;
327 readBigUInt64BE(offset?: number): bigint;
328 /**
329 * @alias Buffer.readBigUInt64BE
330 * @since v14.10.0, v12.19.0
331 */
332 readBigUint64BE(offset?: number): bigint;
333 readBigUInt64LE(offset?: number): bigint;
334 /**
335 * @alias Buffer.readBigUInt64LE
336 * @since v14.10.0, v12.19.0
337 */
338 readBigUint64LE(offset?: number): bigint;
339 readBigInt64BE(offset?: number): bigint;
340 readBigInt64LE(offset?: number): bigint;
341 readUIntLE(offset: number, byteLength: number): number;
342 /**
343 * @alias Buffer.readUIntLE
344 * @since v14.9.0, v12.19.0
345 */
346 readUintLE(offset: number, byteLength: number): number;
347 readUIntBE(offset: number, byteLength: number): number;
348 /**
349 * @alias Buffer.readUIntBE
350 * @since v14.9.0, v12.19.0
351 */
352 readUintBE(offset: number, byteLength: number): number;
353 readIntLE(offset: number, byteLength: number): number;
354 readIntBE(offset: number, byteLength: number): number;
355 readUInt8(offset?: number): number;
356 /**
357 * @alias Buffer.readUInt8
358 * @since v14.9.0, v12.19.0
359 */
360 readUint8(offset?: number): number;
361 readUInt16LE(offset?: number): number;
362 /**
363 * @alias Buffer.readUInt16LE
364 * @since v14.9.0, v12.19.0
365 */
366 readUint16LE(offset?: number): number;
367 readUInt16BE(offset?: number): number;
368 /**
369 * @alias Buffer.readUInt16BE
370 * @since v14.9.0, v12.19.0
371 */
372 readUint16BE(offset?: number): number;
373 readUInt32LE(offset?: number): number;
374 /**
375 * @alias Buffer.readUInt32LE
376 * @since v14.9.0, v12.19.0
377 */
378 readUint32LE(offset?: number): number;
379 readUInt32BE(offset?: number): number;
380 /**
381 * @alias Buffer.readUInt32BE
382 * @since v14.9.0, v12.19.0
383 */
384 readUint32BE(offset?: number): number;
385 readInt8(offset?: number): number;
386 readInt16LE(offset?: number): number;
387 readInt16BE(offset?: number): number;
388 readInt32LE(offset?: number): number;
389 readInt32BE(offset?: number): number;
390 readFloatLE(offset?: number): number;
391 readFloatBE(offset?: number): number;
392 readDoubleLE(offset?: number): number;
393 readDoubleBE(offset?: number): number;
394 reverse(): this;
395 swap16(): Buffer;
396 swap32(): Buffer;
397 swap64(): Buffer;
398 writeUInt8(value: number, offset?: number): number;
399 /**
400 * @alias Buffer.writeUInt8
401 * @since v14.9.0, v12.19.0
402 */
403 writeUint8(value: number, offset?: number): number;
404 writeUInt16LE(value: number, offset?: number): number;
405 /**
406 * @alias Buffer.writeUInt16LE
407 * @since v14.9.0, v12.19.0
408 */
409 writeUint16LE(value: number, offset?: number): number;
410 writeUInt16BE(value: number, offset?: number): number;
411 /**
412 * @alias Buffer.writeUInt16BE
413 * @since v14.9.0, v12.19.0
414 */
415 writeUint16BE(value: number, offset?: number): number;
416 writeUInt32LE(value: number, offset?: number): number;
417 /**
418 * @alias Buffer.writeUInt32LE
419 * @since v14.9.0, v12.19.0
420 */
421 writeUint32LE(value: number, offset?: number): number;
422 writeUInt32BE(value: number, offset?: number): number;
423 /**
424 * @alias Buffer.writeUInt32BE
425 * @since v14.9.0, v12.19.0
426 */
427 writeUint32BE(value: number, offset?: number): number;
428 writeInt8(value: number, offset?: number): number;
429 writeInt16LE(value: number, offset?: number): number;
430 writeInt16BE(value: number, offset?: number): number;
431 writeInt32LE(value: number, offset?: number): number;
432 writeInt32BE(value: number, offset?: number): number;
433 writeFloatLE(value: number, offset?: number): number;
434 writeFloatBE(value: number, offset?: number): number;
435 writeDoubleLE(value: number, offset?: number): number;
436 writeDoubleBE(value: number, offset?: number): number;
437
438 fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
439
440 indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
441 lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
442 entries(): IterableIterator<[number, number]>;
443 includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
444 keys(): IterableIterator<number>;
445 values(): IterableIterator<number>;
446}
447
448/*----------------------------------------------*
449* *
450* GLOBAL INTERFACES *
451* *
452*-----------------------------------------------*/
453declare namespace NodeJS {
454 interface InspectOptions {
455 /**
456 * If set to `true`, getters are going to be
457 * inspected as well. If set to `'get'` only getters without setter are going
458 * to be inspected. If set to `'set'` only getters having a corresponding
459 * setter are going to be inspected. This might cause side effects depending on
460 * the getter function.
461 * @default `false`
462 */
463 getters?: 'get' | 'set' | boolean | undefined;
464 showHidden?: boolean | undefined;
465 /**
466 * @default 2
467 */
468 depth?: number | null | undefined;
469 colors?: boolean | undefined;
470 customInspect?: boolean | undefined;
471 showProxy?: boolean | undefined;
472 maxArrayLength?: number | null | undefined;
473 /**
474 * Specifies the maximum number of characters to
475 * include when formatting. Set to `null` or `Infinity` to show all elements.
476 * Set to `0` or negative to show no characters.
477 * @default Infinity
478 */
479 maxStringLength?: number | null | undefined;
480 breakLength?: number | undefined;
481 /**
482 * Setting this to `false` causes each object key
483 * to be displayed on a new line. It will also add new lines to text that is
484 * longer than `breakLength`. If set to a number, the most `n` inner elements
485 * are united on a single line as long as all properties fit into
486 * `breakLength`. Short array elements are also grouped together. Note that no
487 * text will be reduced below 16 characters, no matter the `breakLength` size.
488 * For more information, see the example below.
489 * @default `true`
490 */
491 compact?: boolean | number | undefined;
492 sorted?: boolean | ((a: string, b: string) => number) | undefined;
493 }
494
495 interface CallSite {
496 /**
497 * Value of "this"
498 */
499 getThis(): any;
500
501 /**
502 * Type of "this" as a string.
503 * This is the name of the function stored in the constructor field of
504 * "this", if available. Otherwise the object's [[Class]] internal
505 * property.
506 */
507 getTypeName(): string | null;
508
509 /**
510 * Current function
511 */
512 getFunction(): Function | undefined;
513
514 /**
515 * Name of the current function, typically its name property.
516 * If a name property is not available an attempt will be made to try
517 * to infer a name from the function's context.
518 */
519 getFunctionName(): string | null;
520
521 /**
522 * Name of the property [of "this" or one of its prototypes] that holds
523 * the current function
524 */
525 getMethodName(): string | null;
526
527 /**
528 * Name of the script [if this function was defined in a script]
529 */
530 getFileName(): string | null;
531
532 /**
533 * Current line number [if this function was defined in a script]
534 */
535 getLineNumber(): number | null;
536
537 /**
538 * Current column number [if this function was defined in a script]
539 */
540 getColumnNumber(): number | null;
541
542 /**
543 * A call site object representing the location where eval was called
544 * [if this function was created using a call to eval]
545 */
546 getEvalOrigin(): string | undefined;
547
548 /**
549 * Is this a toplevel invocation, that is, is "this" the global object?
550 */
551 isToplevel(): boolean;
552
553 /**
554 * Does this call take place in code defined by a call to eval?
555 */
556 isEval(): boolean;
557
558 /**
559 * Is this call in native V8 code?
560 */
561 isNative(): boolean;
562
563 /**
564 * Is this a constructor call?
565 */
566 isConstructor(): boolean;
567 }
568
569 interface ErrnoException extends Error {
570 errno?: number | undefined;
571 code?: string | undefined;
572 path?: string | undefined;
573 syscall?: string | undefined;
574 }
575
576 interface ReadableStream extends EventEmitter {
577 readable: boolean;
578 read(size?: number): string | Buffer;
579 setEncoding(encoding: BufferEncoding): this;
580 pause(): this;
581 resume(): this;
582 isPaused(): boolean;
583 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined; }): T;
584 unpipe(destination?: WritableStream): this;
585 unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
586 wrap(oldStream: ReadableStream): this;
587 [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
588 }
589
590 interface WritableStream extends EventEmitter {
591 writable: boolean;
592 write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
593 write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
594 end(cb?: () => void): this;
595 end(data: string | Uint8Array, cb?: () => void): this;
596 end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
597 }
598
599 interface ReadWriteStream extends ReadableStream, WritableStream { }
600
601 interface Global {
602 Array: typeof Array;
603 ArrayBuffer: typeof ArrayBuffer;
604 Boolean: typeof Boolean;
605 Buffer: typeof Buffer;
606 DataView: typeof DataView;
607 Date: typeof Date;
608 Error: typeof Error;
609 EvalError: typeof EvalError;
610 Float32Array: typeof Float32Array;
611 Float64Array: typeof Float64Array;
612 Function: typeof Function;
613 Infinity: typeof Infinity;
614 Int16Array: typeof Int16Array;
615 Int32Array: typeof Int32Array;
616 Int8Array: typeof Int8Array;
617 Intl: typeof Intl;
618 JSON: typeof JSON;
619 Map: MapConstructor;
620 Math: typeof Math;
621 NaN: typeof NaN;
622 Number: typeof Number;
623 Object: typeof Object;
624 Promise: typeof Promise;
625 RangeError: typeof RangeError;
626 ReferenceError: typeof ReferenceError;
627 RegExp: typeof RegExp;
628 Set: SetConstructor;
629 String: typeof String;
630 Symbol: Function;
631 SyntaxError: typeof SyntaxError;
632 TypeError: typeof TypeError;
633 URIError: typeof URIError;
634 Uint16Array: typeof Uint16Array;
635 Uint32Array: typeof Uint32Array;
636 Uint8Array: typeof Uint8Array;
637 Uint8ClampedArray: typeof Uint8ClampedArray;
638 WeakMap: WeakMapConstructor;
639 WeakSet: WeakSetConstructor;
640 clearImmediate: (immediateId: Immediate) => void;
641 clearInterval: (intervalId: Timeout) => void;
642 clearTimeout: (timeoutId: Timeout) => void;
643 decodeURI: typeof decodeURI;
644 decodeURIComponent: typeof decodeURIComponent;
645 encodeURI: typeof encodeURI;
646 encodeURIComponent: typeof encodeURIComponent;
647 escape: (str: string) => string;
648 eval: typeof eval;
649 global: Global;
650 isFinite: typeof isFinite;
651 isNaN: typeof isNaN;
652 parseFloat: typeof parseFloat;
653 parseInt: typeof parseInt;
654 setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
655 setInterval: (callback: (...args: any[]) => void, ms?: number, ...args: any[]) => Timeout;
656 setTimeout: (callback: (...args: any[]) => void, ms?: number, ...args: any[]) => Timeout;
657 queueMicrotask: typeof queueMicrotask;
658 undefined: typeof undefined;
659 unescape: (str: string) => string;
660 gc: () => void;
661 v8debug?: any;
662 }
663
664 interface RefCounted {
665 ref(): this;
666 unref(): this;
667 }
668
669 // compatibility with older typings
670 interface Timer extends RefCounted {
671 hasRef(): boolean;
672 refresh(): this;
673 [Symbol.toPrimitive](): number;
674 }
675
676 interface Immediate extends RefCounted {
677 hasRef(): boolean;
678 _onImmediate: Function; // to distinguish it from the Timeout class
679 }
680
681 interface Timeout extends Timer {
682 hasRef(): boolean;
683 refresh(): this;
684 [Symbol.toPrimitive](): number;
685 }
686
687 type TypedArray =
688 | Uint8Array
689 | Uint8ClampedArray
690 | Uint16Array
691 | Uint32Array
692 | Int8Array
693 | Int16Array
694 | Int32Array
695 | BigUint64Array
696 | BigInt64Array
697 | Float32Array
698 | Float64Array;
699 type ArrayBufferView = TypedArray | DataView;
700
701 interface Require {
702 (id: string): any;
703 resolve: RequireResolve;
704 cache: Dict<NodeModule>;
705 /**
706 * @deprecated
707 */
708 extensions: RequireExtensions;
709 main: Module | undefined;
710 }
711
712 interface RequireResolve {
713 (id: string, options?: { paths?: string[] | undefined; }): string;
714 paths(request: string): string[] | null;
715 }
716
717 interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
718 '.js': (m: Module, filename: string) => any;
719 '.json': (m: Module, filename: string) => any;
720 '.node': (m: Module, filename: string) => any;
721 }
722 interface Module {
723 exports: any;
724 require: Require;
725 id: string;
726 filename: string;
727 loaded: boolean;
728 /** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
729 parent: Module | null | undefined;
730 children: Module[];
731 /**
732 * @since v11.14.0
733 *
734 * The directory name of the module. This is usually the same as the path.dirname() of the module.id.
735 */
736 path: string;
737 paths: string[];
738 }
739
740 interface Dict<T> {
741 [key: string]: T | undefined;
742 }
743
744 interface ReadOnlyDict<T> {
745 readonly [key: string]: T | undefined;
746 }
747}