1 |
|
2 | interface ErrorConstructor {
|
3 |
|
4 | captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
5 |
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 | prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
|
12 |
|
13 | stackTraceLimit: number;
|
14 | }
|
15 |
|
16 |
|
17 | interface String {
|
18 |
|
19 | trimLeft(): string;
|
20 |
|
21 | trimRight(): string;
|
22 |
|
23 |
|
24 | trimStart(): string;
|
25 |
|
26 | trimEnd(): string;
|
27 | }
|
28 |
|
29 | interface ImportMeta {
|
30 | url: string;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | interface NodeRequire extends NodeJS.Require {}
|
41 | interface RequireResolve extends NodeJS.RequireResolve {}
|
42 | interface NodeModule extends NodeJS.Module {}
|
43 |
|
44 | declare var process: NodeJS.Process;
|
45 | declare var console: Console;
|
46 |
|
47 | declare var __filename: string;
|
48 | declare var __dirname: string;
|
49 |
|
50 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
|
51 | declare namespace setTimeout {
|
52 | function __promisify__(ms: number): Promise<void>;
|
53 | function __promisify__<T>(ms: number, value: T): Promise<T>;
|
54 | }
|
55 | declare function clearTimeout(timeoutId: NodeJS.Timeout): void;
|
56 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout;
|
57 | declare function clearInterval(intervalId: NodeJS.Timeout): void;
|
58 | declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
|
59 | declare namespace setImmediate {
|
60 | function __promisify__(): Promise<void>;
|
61 | function __promisify__<T>(value: T): Promise<T>;
|
62 | }
|
63 | declare function clearImmediate(immediateId: NodeJS.Immediate): void;
|
64 |
|
65 | declare function queueMicrotask(callback: () => void): void;
|
66 |
|
67 | declare var require: NodeRequire;
|
68 | declare var module: NodeModule;
|
69 |
|
70 | // Same as module.exports
|
71 | declare var exports: any;
|
72 |
|
73 | // Buffer class
|
74 | type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
75 |
|
76 | type WithImplicitCoercion<T> = T | { valueOf(): T };
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | declare class Buffer extends Uint8Array {
|
84 | |
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | constructor(str: string, encoding?: BufferEncoding);
|
92 | /**
|
93 | * Allocates a new buffer of {size} octets.
|
94 | *
|
95 | * @param size count of octets to allocate.
|
96 | * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
97 | */
|
98 | constructor(size: number);
|
99 | /**
|
100 | * Allocates a new buffer containing the given {array} of octets.
|
101 | *
|
102 | * @param array The octets to store.
|
103 | * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
104 | */
|
105 | constructor(array: Uint8Array);
|
106 | /**
|
107 | * Produces a Buffer backed by the same allocated memory as
|
108 | * the given {ArrayBuffer}/{SharedArrayBuffer}.
|
109 | *
|
110 | *
|
111 | * @param arrayBuffer The ArrayBuffer with which to share memory.
|
112 | * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
113 | */
|
114 | constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
|
115 | /**
|
116 | * Allocates a new buffer containing the given {array} of octets.
|
117 | *
|
118 | * @param array The octets to store.
|
119 | * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
120 | */
|
121 | constructor(array: ReadonlyArray<any>);
|
122 | /**
|
123 | * Copies the passed {buffer} data onto a new {Buffer} instance.
|
124 | *
|
125 | * @param buffer The buffer to copy.
|
126 | * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
127 | */
|
128 | constructor(buffer: Buffer);
|
129 | /**
|
130 | * When passed a reference to the .buffer property of a TypedArray instance,
|
131 | * the newly created Buffer will share the same allocated memory as the TypedArray.
|
132 | * The optional {byteOffset} and {length} arguments specify a memory range
|
133 | * within the {arrayBuffer} that will be shared by the Buffer.
|
134 | *
|
135 | * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
|
136 | */
|
137 | static from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
|
138 | |
139 |
|
140 |
|
141 |
|
142 | static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
|
143 | static from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 | static from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
|
150 | |
151 |
|
152 |
|
153 |
|
154 | static of(...items: number[]): Buffer;
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 | static isBuffer(obj: any): obj is Buffer;
|
161 | |
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | static isEncoding(encoding: string): encoding is BufferEncoding;
|
168 | |
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | static byteLength(
|
176 | string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
177 | encoding?: BufferEncoding
|
178 | ): number;
|
179 | |
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | static concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
|
191 | |
192 |
|
193 |
|
194 | static compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
195 | |
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 | static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
204 | |
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | static allocUnsafe(size: number): Buffer;
|
211 | |
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | static allocUnsafeSlow(size: number): Buffer;
|
218 | |
219 |
|
220 |
|
221 | static poolSize: number;
|
222 |
|
223 | write(string: string, encoding?: BufferEncoding): number;
|
224 | write(string: string, offset: number, encoding?: BufferEncoding): number;
|
225 | write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
|
226 | toString(encoding?: BufferEncoding, start?: number, end?: number): string;
|
227 | toJSON(): { type: 'Buffer'; data: number[] };
|
228 | equals(otherBuffer: Uint8Array): boolean;
|
229 | compare(
|
230 | otherBuffer: Uint8Array,
|
231 | targetStart?: number,
|
232 | targetEnd?: number,
|
233 | sourceStart?: number,
|
234 | sourceEnd?: number
|
235 | ): number;
|
236 | copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
237 | |
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 | slice(begin?: number, end?: number): Buffer;
|
246 | |
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 | subarray(begin?: number, end?: number): Buffer;
|
255 | writeBigInt64BE(value: bigint, offset?: number): number;
|
256 | writeBigInt64LE(value: bigint, offset?: number): number;
|
257 | writeBigUInt64BE(value: bigint, offset?: number): number;
|
258 | writeBigUInt64LE(value: bigint, offset?: number): number;
|
259 | writeUIntLE(value: number, offset: number, byteLength: number): number;
|
260 | writeUIntBE(value: number, offset: number, byteLength: number): number;
|
261 | writeIntLE(value: number, offset: number, byteLength: number): number;
|
262 | writeIntBE(value: number, offset: number, byteLength: number): number;
|
263 | readBigUInt64BE(offset?: number): bigint;
|
264 | readBigUInt64LE(offset?: number): bigint;
|
265 | readBigInt64BE(offset?: number): bigint;
|
266 | readBigInt64LE(offset?: number): bigint;
|
267 | readUIntLE(offset: number, byteLength: number): number;
|
268 | readUIntBE(offset: number, byteLength: number): number;
|
269 | readIntLE(offset: number, byteLength: number): number;
|
270 | readIntBE(offset: number, byteLength: number): number;
|
271 | readUInt8(offset?: number): number;
|
272 | readUInt16LE(offset?: number): number;
|
273 | readUInt16BE(offset?: number): number;
|
274 | readUInt32LE(offset?: number): number;
|
275 | readUInt32BE(offset?: number): number;
|
276 | readInt8(offset?: number): number;
|
277 | readInt16LE(offset?: number): number;
|
278 | readInt16BE(offset?: number): number;
|
279 | readInt32LE(offset?: number): number;
|
280 | readInt32BE(offset?: number): number;
|
281 | readFloatLE(offset?: number): number;
|
282 | readFloatBE(offset?: number): number;
|
283 | readDoubleLE(offset?: number): number;
|
284 | readDoubleBE(offset?: number): number;
|
285 | reverse(): this;
|
286 | swap16(): Buffer;
|
287 | swap32(): Buffer;
|
288 | swap64(): Buffer;
|
289 | writeUInt8(value: number, offset?: number): number;
|
290 | writeUInt16LE(value: number, offset?: number): number;
|
291 | writeUInt16BE(value: number, offset?: number): number;
|
292 | writeUInt32LE(value: number, offset?: number): number;
|
293 | writeUInt32BE(value: number, offset?: number): number;
|
294 | writeInt8(value: number, offset?: number): number;
|
295 | writeInt16LE(value: number, offset?: number): number;
|
296 | writeInt16BE(value: number, offset?: number): number;
|
297 | writeInt32LE(value: number, offset?: number): number;
|
298 | writeInt32BE(value: number, offset?: number): number;
|
299 | writeFloatLE(value: number, offset?: number): number;
|
300 | writeFloatBE(value: number, offset?: number): number;
|
301 | writeDoubleLE(value: number, offset?: number): number;
|
302 | writeDoubleBE(value: number, offset?: number): number;
|
303 |
|
304 | fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
|
305 |
|
306 | indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
307 | lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
308 | entries(): IterableIterator<[number, number]>;
|
309 | includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
|
310 | keys(): IterableIterator<number>;
|
311 | values(): IterableIterator<number>;
|
312 | }
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 | declare namespace NodeJS {
|
320 | interface InspectOptions {
|
321 | |
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | getters?: 'get' | 'set' | boolean;
|
330 | showHidden?: boolean;
|
331 | |
332 |
|
333 |
|
334 | depth?: number | null;
|
335 | colors?: boolean;
|
336 | customInspect?: boolean;
|
337 | showProxy?: boolean;
|
338 | maxArrayLength?: number | null;
|
339 | |
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 | maxStringLength?: number | null;
|
346 | breakLength?: number;
|
347 | |
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | compact?: boolean | number;
|
358 | sorted?: boolean | ((a: string, b: string) => number);
|
359 | }
|
360 |
|
361 | interface CallSite {
|
362 | /**
|
363 | * Value of "this"
|
364 | */
|
365 | getThis(): any;
|
366 |
|
367 | /**
|
368 | * Type of "this" as a string.
|
369 | * This is the name of the function stored in the constructor field of
|
370 | * "this", if available. Otherwise the object's [[Class]] internal
|
371 | * property.
|
372 | */
|
373 | getTypeName(): string | null;
|
374 |
|
375 | /**
|
376 | * Current function
|
377 | */
|
378 | getFunction(): Function | undefined;
|
379 |
|
380 | /**
|
381 | * Name of the current function, typically its name property.
|
382 | * If a name property is not available an attempt will be made to try
|
383 | * to infer a name from the function's context.
|
384 | */
|
385 | getFunctionName(): string | null;
|
386 |
|
387 | /**
|
388 | * Name of the property [of "this" or one of its prototypes] that holds
|
389 | * the current function
|
390 | */
|
391 | getMethodName(): string | null;
|
392 |
|
393 | /**
|
394 | * Name of the script [if this function was defined in a script]
|
395 | */
|
396 | getFileName(): string | null;
|
397 |
|
398 | /**
|
399 | * Current line number [if this function was defined in a script]
|
400 | */
|
401 | getLineNumber(): number | null;
|
402 |
|
403 | /**
|
404 | * Current column number [if this function was defined in a script]
|
405 | */
|
406 | getColumnNumber(): number | null;
|
407 |
|
408 | /**
|
409 | * A call site object representing the location where eval was called
|
410 | * [if this function was created using a call to eval]
|
411 | */
|
412 | getEvalOrigin(): string | undefined;
|
413 |
|
414 | /**
|
415 | * Is this a toplevel invocation, that is, is "this" the global object?
|
416 | */
|
417 | isToplevel(): boolean;
|
418 |
|
419 | /**
|
420 | * Does this call take place in code defined by a call to eval?
|
421 | */
|
422 | isEval(): boolean;
|
423 |
|
424 | /**
|
425 | * Is this call in native V8 code?
|
426 | */
|
427 | isNative(): boolean;
|
428 |
|
429 | /**
|
430 | * Is this a constructor call?
|
431 | */
|
432 | isConstructor(): boolean;
|
433 | }
|
434 |
|
435 | interface ErrnoException extends Error {
|
436 | errno?: number;
|
437 | code?: string;
|
438 | path?: string;
|
439 | syscall?: string;
|
440 | stack?: string;
|
441 | }
|
442 |
|
443 | interface ReadableStream extends EventEmitter {
|
444 | readable: boolean;
|
445 | read(size?: number): string | Buffer;
|
446 | setEncoding(encoding: BufferEncoding): this;
|
447 | pause(): this;
|
448 | resume(): this;
|
449 | isPaused(): boolean;
|
450 | pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
451 | unpipe(destination?: WritableStream): this;
|
452 | unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
453 | wrap(oldStream: ReadableStream): this;
|
454 | [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
455 | }
|
456 |
|
457 | interface WritableStream extends EventEmitter {
|
458 | writable: boolean;
|
459 | write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
460 | write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
461 | end(cb?: () => void): void;
|
462 | end(data: string | Uint8Array, cb?: () => void): void;
|
463 | end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
|
464 | }
|
465 |
|
466 | interface ReadWriteStream extends ReadableStream, WritableStream { }
|
467 |
|
468 | interface Global {
|
469 | Array: typeof Array;
|
470 | ArrayBuffer: typeof ArrayBuffer;
|
471 | Boolean: typeof Boolean;
|
472 | Buffer: typeof Buffer;
|
473 | DataView: typeof DataView;
|
474 | Date: typeof Date;
|
475 | Error: typeof Error;
|
476 | EvalError: typeof EvalError;
|
477 | Float32Array: typeof Float32Array;
|
478 | Float64Array: typeof Float64Array;
|
479 | Function: typeof Function;
|
480 | Infinity: typeof Infinity;
|
481 | Int16Array: typeof Int16Array;
|
482 | Int32Array: typeof Int32Array;
|
483 | Int8Array: typeof Int8Array;
|
484 | Intl: typeof Intl;
|
485 | JSON: typeof JSON;
|
486 | Map: MapConstructor;
|
487 | Math: typeof Math;
|
488 | NaN: typeof NaN;
|
489 | Number: typeof Number;
|
490 | Object: typeof Object;
|
491 | Promise: typeof Promise;
|
492 | RangeError: typeof RangeError;
|
493 | ReferenceError: typeof ReferenceError;
|
494 | RegExp: typeof RegExp;
|
495 | Set: SetConstructor;
|
496 | String: typeof String;
|
497 | Symbol: Function;
|
498 | SyntaxError: typeof SyntaxError;
|
499 | TypeError: typeof TypeError;
|
500 | URIError: typeof URIError;
|
501 | Uint16Array: typeof Uint16Array;
|
502 | Uint32Array: typeof Uint32Array;
|
503 | Uint8Array: typeof Uint8Array;
|
504 | Uint8ClampedArray: typeof Uint8ClampedArray;
|
505 | WeakMap: WeakMapConstructor;
|
506 | WeakSet: WeakSetConstructor;
|
507 | clearImmediate: (immediateId: Immediate) => void;
|
508 | clearInterval: (intervalId: Timeout) => void;
|
509 | clearTimeout: (timeoutId: Timeout) => void;
|
510 | decodeURI: typeof decodeURI;
|
511 | decodeURIComponent: typeof decodeURIComponent;
|
512 | encodeURI: typeof encodeURI;
|
513 | encodeURIComponent: typeof encodeURIComponent;
|
514 | escape: (str: string) => string;
|
515 | eval: typeof eval;
|
516 | global: Global;
|
517 | isFinite: typeof isFinite;
|
518 | isNaN: typeof isNaN;
|
519 | parseFloat: typeof parseFloat;
|
520 | parseInt: typeof parseInt;
|
521 | setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
|
522 | setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
|
523 | setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
|
524 | queueMicrotask: typeof queueMicrotask;
|
525 | undefined: typeof undefined;
|
526 | unescape: (str: string) => string;
|
527 | gc: () => void;
|
528 | v8debug?: any;
|
529 | }
|
530 |
|
531 | interface RefCounted {
|
532 | ref(): this;
|
533 | unref(): this;
|
534 | }
|
535 |
|
536 |
|
537 | interface Timer extends RefCounted {
|
538 | hasRef(): boolean;
|
539 | refresh(): this;
|
540 | [Symbol.toPrimitive](): number;
|
541 | }
|
542 |
|
543 | interface Immediate extends RefCounted {
|
544 | hasRef(): boolean;
|
545 | _onImmediate: Function;
|
546 | }
|
547 |
|
548 | interface Timeout extends Timer {
|
549 | hasRef(): boolean;
|
550 | refresh(): this;
|
551 | [Symbol.toPrimitive](): number;
|
552 | }
|
553 |
|
554 | type TypedArray =
|
555 | | Uint8Array
|
556 | | Uint8ClampedArray
|
557 | | Uint16Array
|
558 | | Uint32Array
|
559 | | Int8Array
|
560 | | Int16Array
|
561 | | Int32Array
|
562 | | BigUint64Array
|
563 | | BigInt64Array
|
564 | | Float32Array
|
565 | | Float64Array;
|
566 | type ArrayBufferView = TypedArray | DataView;
|
567 |
|
568 | interface Require {
|
569 | (id: string): any;
|
570 | resolve: RequireResolve;
|
571 | cache: Dict<NodeModule>;
|
572 | |
573 |
|
574 |
|
575 | extensions: RequireExtensions;
|
576 | main: Module | undefined;
|
577 | }
|
578 |
|
579 | interface RequireResolve {
|
580 | (id: string, options?: { paths?: string[]; }): string;
|
581 | paths(request: string): string[] | null;
|
582 | }
|
583 |
|
584 | interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
|
585 | '.js': (m: Module, filename: string) => any;
|
586 | '.json': (m: Module, filename: string) => any;
|
587 | '.node': (m: Module, filename: string) => any;
|
588 | }
|
589 | interface Module {
|
590 | exports: any;
|
591 | require: Require;
|
592 | id: string;
|
593 | filename: string;
|
594 | loaded: boolean;
|
595 |
|
596 | parent: Module | null | undefined;
|
597 | children: Module[];
|
598 | |
599 |
|
600 |
|
601 |
|
602 |
|
603 | path: string;
|
604 | paths: string[];
|
605 | }
|
606 |
|
607 | interface Dict<T> {
|
608 | [key: string]: T | undefined;
|
609 | }
|
610 |
|
611 | interface ReadOnlyDict<T> {
|
612 | readonly [key: string]: T | undefined;
|
613 | }
|
614 | }
|