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