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