UNPKG

412 kBTypeScriptView Raw
1// Type definitions for Node.js 10.5.x
2// Project: http://nodejs.org/
3// Definitions by: Microsoft TypeScript <http://typescriptlang.org>
4// DefinitelyTyped <https://github.com/DefinitelyTyped/DefinitelyTyped>
5// Parambir Singh <https://github.com/parambirs>
6// Christian Vaagland Tellnes <https://github.com/tellnes>
7// Wilco Bakker <https://github.com/WilcoBakker>
8// Nicolas Voigt <https://github.com/octo-sniffle>
9// Chigozirim C. <https://github.com/smac89>
10// Flarna <https://github.com/Flarna>
11// Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
12// wwwy3y3 <https://github.com/wwwy3y3>
13// Deividas Bakanas <https://github.com/DeividasBakanas>
14// Kelvin Jin <https://github.com/kjin>
15// Alvis HT Tang <https://github.com/alvis>
16// Sebastian Silbermann <https://github.com/eps1lon>
17// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
18// Alberto Schiabel <https://github.com/jkomyno>
19// Klaus Meinhardt <https://github.com/ajafff>
20// Huw <https://github.com/hoo29>
21// Nicolas Even <https://github.com/n-e>
22// Bruno Scheufler <https://github.com/brunoscheufler>
23// Mohsen Azimi <https://github.com/mohsen1>
24// Hoàng Văn Khải <https://github.com/KSXGitHub>
25// Alexander T. <https://github.com/a-tarasyuk>
26// Lishude <https://github.com/islishude>
27// Andrew Makarov <https://github.com/r3nya>
28// Zane Hannan AU <https://github.com/ZaneHannanAU>
29// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
30
31/** inspector module types */
32/// <reference path="./inspector.d.ts" />
33
34// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
35interface Console {
36 Console: NodeJS.ConsoleConstructor;
37 /**
38 * A simple assertion test that verifies whether `value` is truthy.
39 * If it is not, an `AssertionError` is thrown.
40 * If provided, the error `message` is formatted using `util.format()` and used as the error message.
41 */
42 assert(value: any, message?: string, ...optionalParams: any[]): void;
43 /**
44 * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
45 * When `stdout` is not a TTY, this method does nothing.
46 */
47 clear(): void;
48 /**
49 * Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
50 */
51 count(label?: string): void;
52 /**
53 * Resets the internal counter specific to `label`.
54 */
55 countReset(label?: string): void;
56 /**
57 * The `console.debug()` function is an alias for {@link console.log()}.
58 */
59 debug(message?: any, ...optionalParams: any[]): void;
60 /**
61 * Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
62 * This function bypasses any custom `inspect()` function defined on `obj`.
63 */
64 dir(obj: any, options?: NodeJS.InspectOptions): void;
65 /**
66 * This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
67 */
68 dirxml(...data: any[]): void;
69 /**
70 * Prints to `stderr` with newline.
71 */
72 error(message?: any, ...optionalParams: any[]): void;
73 /**
74 * Increases indentation of subsequent lines by two spaces.
75 * If one or more `label`s are provided, those are printed first without the additional indentation.
76 */
77 group(...label: any[]): void;
78 /**
79 * The `console.groupCollapsed()` function is an alias for {@link console.group()}.
80 */
81 groupCollapsed(): void;
82 /**
83 * Decreases indentation of subsequent lines by two spaces.
84 */
85 groupEnd(): void;
86 /**
87 * The {@link console.info()} function is an alias for {@link console.log()}.
88 */
89 info(message?: any, ...optionalParams: any[]): void;
90 /**
91 * Prints to `stdout` with newline.
92 */
93 log(message?: any, ...optionalParams: any[]): void;
94 /**
95 * This method does not display anything unless used in the inspector.
96 * Prints to `stdout` the array `array` formatted as a table.
97 */
98 table(tabularData: any, properties?: string[]): void;
99 /**
100 * Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
101 */
102 time(label?: string): void;
103 /**
104 * Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
105 */
106 timeEnd(label?: string): void;
107 /**
108 * Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.
109 */
110 trace(message?: any, ...optionalParams: any[]): void;
111 /**
112 * The {@link console.warn()} function is an alias for {@link console.error()}.
113 */
114 warn(message?: any, ...optionalParams: any[]): void;
115
116 // --- Inspector mode only ---
117 /**
118 * This method does not display anything unless used in the inspector.
119 * Starts a JavaScript CPU profile with an optional label.
120 */
121 profile(label?: string): void;
122 /**
123 * This method does not display anything unless used in the inspector.
124 * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
125 */
126 profileEnd(): void;
127 /**
128 * This method does not display anything unless used in the inspector.
129 * Adds an event with the label `label` to the Timeline panel of the inspector.
130 */
131 timeStamp(label?: string): void;
132}
133
134interface Error {
135 stack?: string;
136}
137
138// Declare "static" methods in Error
139interface ErrorConstructor {
140 /** Create .stack property on a target object */
141 captureStackTrace(targetObject: Object, constructorOpt?: Function): void;
142
143 /**
144 * Optional override for formatting stack traces
145 *
146 * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces
147 */
148 prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
149
150 stackTraceLimit: number;
151}
152
153// compat for TypeScript 1.8
154// if you use with --target es3 or --target es5 and use below definitions,
155// use the lib.es6.d.ts that is bundled with TypeScript 1.8.
156interface MapConstructor { }
157interface WeakMapConstructor { }
158interface SetConstructor { }
159interface WeakSetConstructor { }
160
161// Forward-declare needed types from lib.es2015.d.ts (in case users are using `--lib es5`)
162interface Iterable<T> { }
163interface Iterator<T> {
164 next(value?: any): IteratorResult<T>;
165}
166interface IteratorResult<T> { }
167interface AsyncIterableIterator<T> {}
168interface SymbolConstructor {
169 readonly observable: symbol;
170 readonly iterator: symbol;
171 readonly asyncIterator: symbol;
172}
173declare var Symbol: SymbolConstructor;
174
175// Node.js ESNEXT support
176interface String {
177 /** Removes whitespace from the left end of a string. */
178 trimLeft(): string;
179 /** Removes whitespace from the right end of a string. */
180 trimRight(): string;
181}
182
183/************************************************
184* *
185* GLOBAL *
186* *
187************************************************/
188declare var process: NodeJS.Process;
189declare var global: NodeJS.Global;
190declare var console: Console;
191
192declare var __filename: string;
193declare var __dirname: string;
194
195declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
196declare namespace setTimeout {
197 export function __promisify__(ms: number): Promise<void>;
198 export function __promisify__<T>(ms: number, value: T): Promise<T>;
199}
200declare function clearTimeout(timeoutId: NodeJS.Timer): void;
201declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
202declare function clearInterval(intervalId: NodeJS.Timer): void;
203declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
204declare namespace setImmediate {
205 export function __promisify__(): Promise<void>;
206 export function __promisify__<T>(value: T): Promise<T>;
207}
208declare function clearImmediate(immediateId: any): void;
209
210// TODO: change to `type NodeRequireFunction = (id: string) => any;` in next mayor version.
211interface NodeRequireFunction {
212 /* tslint:disable-next-line:callable-types */
213 (id: string): any;
214}
215
216interface NodeRequire extends NodeRequireFunction {
217 resolve: RequireResolve;
218 cache: any;
219 extensions: NodeExtensions;
220 main: NodeModule | undefined;
221}
222
223interface RequireResolve {
224 (id: string, options?: { paths?: string[]; }): string;
225 paths(request: string): string[] | null;
226}
227
228interface NodeExtensions {
229 '.js': (m: NodeModule, filename: string) => any;
230 '.json': (m: NodeModule, filename: string) => any;
231 '.node': (m: NodeModule, filename: string) => any;
232 [ext: string]: (m: NodeModule, filename: string) => any;
233}
234
235declare var require: NodeRequire;
236
237interface NodeModule {
238 exports: any;
239 require: NodeRequireFunction;
240 id: string;
241 filename: string;
242 loaded: boolean;
243 parent: NodeModule | null;
244 children: NodeModule[];
245 paths: string[];
246}
247
248declare var module: NodeModule;
249
250// Same as module.exports
251declare var exports: any;
252declare var SlowBuffer: {
253 new(str: string, encoding?: string): Buffer;
254 new(size: number): Buffer;
255 new(size: Uint8Array): Buffer;
256 new(array: any[]): Buffer;
257 prototype: Buffer;
258 isBuffer(obj: any): boolean;
259 byteLength(string: string, encoding?: string): number;
260 concat(list: Buffer[], totalLength?: number): Buffer;
261};
262
263// Buffer class
264type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex";
265interface Buffer extends Uint8Array {
266 write(string: string, offset?: number, length?: number, encoding?: string): number;
267 toString(encoding?: string, start?: number, end?: number): string;
268 toJSON(): { type: 'Buffer', data: any[] };
269 equals(otherBuffer: Uint8Array): boolean;
270 compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
271 copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
272 slice(start?: number, end?: number): Buffer;
273 writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
274 writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
275 writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
276 writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
277 readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
278 readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
279 readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
280 readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
281 readUInt8(offset: number, noAssert?: boolean): number;
282 readUInt16LE(offset: number, noAssert?: boolean): number;
283 readUInt16BE(offset: number, noAssert?: boolean): number;
284 readUInt32LE(offset: number, noAssert?: boolean): number;
285 readUInt32BE(offset: number, noAssert?: boolean): number;
286 readInt8(offset: number, noAssert?: boolean): number;
287 readInt16LE(offset: number, noAssert?: boolean): number;
288 readInt16BE(offset: number, noAssert?: boolean): number;
289 readInt32LE(offset: number, noAssert?: boolean): number;
290 readInt32BE(offset: number, noAssert?: boolean): number;
291 readFloatLE(offset: number, noAssert?: boolean): number;
292 readFloatBE(offset: number, noAssert?: boolean): number;
293 readDoubleLE(offset: number, noAssert?: boolean): number;
294 readDoubleBE(offset: number, noAssert?: boolean): number;
295 swap16(): Buffer;
296 swap32(): Buffer;
297 swap64(): Buffer;
298 writeUInt8(value: number, offset: number, noAssert?: boolean): number;
299 writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
300 writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
301 writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
302 writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
303 writeInt8(value: number, offset: number, noAssert?: boolean): number;
304 writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
305 writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
306 writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
307 writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
308 writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
309 writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
310 writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
311 writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
312 fill(value: any, offset?: number, end?: number): this;
313 indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number;
314 lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: string): number;
315 entries(): IterableIterator<[number, number]>;
316 includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
317 keys(): IterableIterator<number>;
318 values(): IterableIterator<number>;
319}
320
321/**
322 * Raw data is stored in instances of the Buffer class.
323 * 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.
324 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
325 */
326declare var Buffer: {
327 /**
328 * Allocates a new buffer containing the given {str}.
329 *
330 * @param str String to store in buffer.
331 * @param encoding encoding to use, optional. Default is 'utf8'
332 * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
333 */
334 new(str: string, encoding?: string): Buffer;
335 /**
336 * Allocates a new buffer of {size} octets.
337 *
338 * @param size count of octets to allocate.
339 * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
340 */
341 new(size: number): Buffer;
342 /**
343 * Allocates a new buffer containing the given {array} of octets.
344 *
345 * @param array The octets to store.
346 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
347 */
348 new(array: Uint8Array): Buffer;
349 /**
350 * Produces a Buffer backed by the same allocated memory as
351 * the given {ArrayBuffer}.
352 *
353 *
354 * @param arrayBuffer The ArrayBuffer with which to share memory.
355 * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
356 */
357 new(arrayBuffer: ArrayBuffer): Buffer;
358 /**
359 * Allocates a new buffer containing the given {array} of octets.
360 *
361 * @param array The octets to store.
362 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
363 */
364 new(array: any[]): Buffer;
365 /**
366 * Copies the passed {buffer} data onto a new {Buffer} instance.
367 *
368 * @param buffer The buffer to copy.
369 * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
370 */
371 new(buffer: Buffer): Buffer;
372 prototype: Buffer;
373 /**
374 * When passed a reference to the .buffer property of a TypedArray instance,
375 * the newly created Buffer will share the same allocated memory as the TypedArray.
376 * The optional {byteOffset} and {length} arguments specify a memory range
377 * within the {arrayBuffer} that will be shared by the Buffer.
378 *
379 * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
380 */
381 from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
382 // from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
383 /**
384 * Creates a new Buffer using the passed {data}
385 * @param data data to create a new Buffer
386 */
387 from(data: any[]): Buffer;
388 from(data: Uint8Array): Buffer;
389 /**
390 * Creates a new Buffer containing the given JavaScript string {str}.
391 * If provided, the {encoding} parameter identifies the character encoding.
392 * If not provided, {encoding} defaults to 'utf8'.
393 */
394 from(str: string, encoding?: string): Buffer;
395 /**
396 * Creates a new Buffer using the passed {data}
397 * @param values to create a new Buffer
398 */
399 of(...items: number[]): Buffer;
400 /**
401 * Returns true if {obj} is a Buffer
402 *
403 * @param obj object to test.
404 */
405 isBuffer(obj: any): obj is Buffer;
406 /**
407 * Returns true if {encoding} is a valid encoding argument.
408 * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
409 *
410 * @param encoding string to test.
411 */
412 isEncoding(encoding: string): boolean | undefined;
413 /**
414 * Gives the actual byte length of a string. encoding defaults to 'utf8'.
415 * This is not the same as String.prototype.length since that returns the number of characters in a string.
416 *
417 * @param string string to test.
418 * @param encoding encoding used to evaluate (defaults to 'utf8')
419 */
420 byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number;
421 /**
422 * Returns a buffer which is the result of concatenating all the buffers in the list together.
423 *
424 * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
425 * If the list has exactly one item, then the first item of the list is returned.
426 * If the list has more than one item, then a new Buffer is created.
427 *
428 * @param list An array of Buffer objects to concatenate
429 * @param totalLength Total length of the buffers when concatenated.
430 * 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.
431 */
432 concat(list: Uint8Array[], totalLength?: number): Buffer;
433 /**
434 * The same as buf1.compare(buf2).
435 */
436 compare(buf1: Uint8Array, buf2: Uint8Array): number;
437 /**
438 * Allocates a new buffer of {size} octets.
439 *
440 * @param size count of octets to allocate.
441 * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
442 * If parameter is omitted, buffer will be filled with zeros.
443 * @param encoding encoding used for call to buf.fill while initalizing
444 */
445 alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
446 /**
447 * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
448 * of the newly created Buffer are unknown and may contain sensitive data.
449 *
450 * @param size count of octets to allocate
451 */
452 allocUnsafe(size: number): Buffer;
453 /**
454 * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
455 * of the newly created Buffer are unknown and may contain sensitive data.
456 *
457 * @param size count of octets to allocate
458 */
459 allocUnsafeSlow(size: number): Buffer;
460 /**
461 * 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.
462 */
463 poolSize: number;
464};
465
466/************************************************
467* *
468* GLOBAL INTERFACES *
469* *
470************************************************/
471declare namespace NodeJS {
472 export interface InspectOptions {
473 showHidden?: boolean;
474 depth?: number | null;
475 colors?: boolean;
476 customInspect?: boolean;
477 showProxy?: boolean;
478 maxArrayLength?: number | null;
479 breakLength?: number;
480 compact?: boolean;
481 }
482
483 export interface ConsoleConstructor {
484 prototype: Console;
485 new(stdout: WritableStream, stderr?: WritableStream): Console;
486 }
487
488 export interface CallSite {
489 /**
490 * Value of "this"
491 */
492 getThis(): any;
493
494 /**
495 * Type of "this" as a string.
496 * This is the name of the function stored in the constructor field of
497 * "this", if available. Otherwise the object's [[Class]] internal
498 * property.
499 */
500 getTypeName(): string | null;
501
502 /**
503 * Current function
504 */
505 getFunction(): Function | undefined;
506
507 /**
508 * Name of the current function, typically its name property.
509 * If a name property is not available an attempt will be made to try
510 * to infer a name from the function's context.
511 */
512 getFunctionName(): string | null;
513
514 /**
515 * Name of the property [of "this" or one of its prototypes] that holds
516 * the current function
517 */
518 getMethodName(): string | null;
519
520 /**
521 * Name of the script [if this function was defined in a script]
522 */
523 getFileName(): string | null;
524
525 /**
526 * Current line number [if this function was defined in a script]
527 */
528 getLineNumber(): number | null;
529
530 /**
531 * Current column number [if this function was defined in a script]
532 */
533 getColumnNumber(): number | null;
534
535 /**
536 * A call site object representing the location where eval was called
537 * [if this function was created using a call to eval]
538 */
539 getEvalOrigin(): string | undefined;
540
541 /**
542 * Is this a toplevel invocation, that is, is "this" the global object?
543 */
544 isToplevel(): boolean;
545
546 /**
547 * Does this call take place in code defined by a call to eval?
548 */
549 isEval(): boolean;
550
551 /**
552 * Is this call in native V8 code?
553 */
554 isNative(): boolean;
555
556 /**
557 * Is this a constructor call?
558 */
559 isConstructor(): boolean;
560 }
561
562 export interface ErrnoException extends Error {
563 errno?: number;
564 code?: string;
565 path?: string;
566 syscall?: string;
567 stack?: string;
568 }
569
570 export class EventEmitter {
571 addListener(event: string | symbol, listener: (...args: any[]) => void): this;
572 on(event: string | symbol, listener: (...args: any[]) => void): this;
573 once(event: string | symbol, listener: (...args: any[]) => void): this;
574 removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
575 off(event: string | symbol, listener: (...args: any[]) => void): this;
576 removeAllListeners(event?: string | symbol): this;
577 setMaxListeners(n: number): this;
578 getMaxListeners(): number;
579 listeners(event: string | symbol): Function[];
580 rawListeners(event: string | symbol): Function[];
581 emit(event: string | symbol, ...args: any[]): boolean;
582 listenerCount(type: string | symbol): number;
583 // Added in Node 6...
584 prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
585 prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
586 eventNames(): Array<string | symbol>;
587 }
588
589 export interface ReadableStream extends EventEmitter {
590 readable: boolean;
591 read(size?: number): string | Buffer;
592 setEncoding(encoding: string): this;
593 pause(): this;
594 resume(): this;
595 isPaused(): boolean;
596 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
597 unpipe<T extends WritableStream>(destination?: T): this;
598 unshift(chunk: string): void;
599 unshift(chunk: Buffer): void;
600 wrap(oldStream: ReadableStream): this;
601 [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
602 }
603
604 export interface WritableStream extends EventEmitter {
605 writable: boolean;
606 write(buffer: Buffer | string, cb?: Function): boolean;
607 write(str: string, encoding?: string, cb?: Function): boolean;
608 end(cb?: Function): void;
609 end(buffer: Buffer, cb?: Function): void;
610 end(str: string, cb?: Function): void;
611 end(str: string, encoding?: string, cb?: Function): void;
612 }
613
614 export interface ReadWriteStream extends ReadableStream, WritableStream { }
615
616 export interface Events extends EventEmitter { }
617
618 export interface Domain extends Events {
619 run(fn: Function): void;
620 add(emitter: Events): void;
621 remove(emitter: Events): void;
622 bind(cb: (err: Error, data: any) => any): any;
623 intercept(cb: (data: any) => any): any;
624
625 addListener(event: string, listener: (...args: any[]) => void): this;
626 on(event: string, listener: (...args: any[]) => void): this;
627 once(event: string, listener: (...args: any[]) => void): this;
628 removeListener(event: string, listener: (...args: any[]) => void): this;
629 removeAllListeners(event?: string): this;
630 }
631
632 export interface MemoryUsage {
633 rss: number;
634 heapTotal: number;
635 heapUsed: number;
636 external: number;
637 }
638
639 export interface CpuUsage {
640 user: number;
641 system: number;
642 }
643
644 export interface ProcessVersions {
645 http_parser: string;
646 node: string;
647 v8: string;
648 ares: string;
649 uv: string;
650 zlib: string;
651 modules: string;
652 openssl: string;
653 }
654
655 type Platform = 'aix'
656 | 'android'
657 | 'darwin'
658 | 'freebsd'
659 | 'linux'
660 | 'openbsd'
661 | 'sunos'
662 | 'win32'
663 | 'cygwin';
664
665 type Signals =
666 "SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
667 "SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
668 "SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
669 "SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
670
671 type BeforeExitListener = (code: number) => void;
672 type DisconnectListener = () => void;
673 type ExitListener = (code: number) => void;
674 type RejectionHandledListener = (promise: Promise<any>) => void;
675 type UncaughtExceptionListener = (error: Error) => void;
676 type UnhandledRejectionListener = (reason: any, promise: Promise<any>) => void;
677 type WarningListener = (warning: Error) => void;
678 type MessageListener = (message: any, sendHandle: any) => void;
679 type SignalsListener = (signal: Signals) => void;
680 type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
681 type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
682
683 export interface Socket extends ReadWriteStream {
684 isTTY?: true;
685 }
686
687 export interface ProcessEnv {
688 [key: string]: string | undefined;
689 }
690
691 export interface WriteStream extends Socket {
692 readonly writableHighWaterMark: number;
693 readonly writableLength: number;
694 columns?: number;
695 rows?: number;
696 _write(chunk: any, encoding: string, callback: Function): void;
697 _destroy(err: Error | null, callback: Function): void;
698 _final(callback: Function): void;
699 setDefaultEncoding(encoding: string): this;
700 cork(): void;
701 uncork(): void;
702 destroy(error?: Error): void;
703 }
704 export interface ReadStream extends Socket {
705 readonly readableHighWaterMark: number;
706 readonly readableLength: number;
707 isRaw?: boolean;
708 setRawMode?(mode: boolean): void;
709 _read(size: number): void;
710 _destroy(err: Error | null, callback: Function): void;
711 push(chunk: any, encoding?: string): boolean;
712 destroy(error?: Error): void;
713 }
714
715 export interface Process extends EventEmitter {
716 stdout: WriteStream;
717 stderr: WriteStream;
718 stdin: ReadStream;
719 openStdin(): Socket;
720 argv: string[];
721 argv0: string;
722 execArgv: string[];
723 execPath: string;
724 abort(): void;
725 chdir(directory: string): void;
726 cwd(): string;
727 debugPort: number;
728 emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
729 env: ProcessEnv;
730 exit(code?: number): never;
731 exitCode: number;
732 getgid(): number;
733 setgid(id: number | string): void;
734 getuid(): number;
735 setuid(id: number | string): void;
736 geteuid(): number;
737 seteuid(id: number | string): void;
738 getegid(): number;
739 setegid(id: number | string): void;
740 getgroups(): number[];
741 setgroups(groups: Array<string | number>): void;
742 setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
743 hasUncaughtExceptionCaptureCallback(): boolean;
744 version: string;
745 versions: ProcessVersions;
746 config: {
747 target_defaults: {
748 cflags: any[];
749 default_configuration: string;
750 defines: string[];
751 include_dirs: string[];
752 libraries: string[];
753 };
754 variables: {
755 clang: number;
756 host_arch: string;
757 node_install_npm: boolean;
758 node_install_waf: boolean;
759 node_prefix: string;
760 node_shared_openssl: boolean;
761 node_shared_v8: boolean;
762 node_shared_zlib: boolean;
763 node_use_dtrace: boolean;
764 node_use_etw: boolean;
765 node_use_openssl: boolean;
766 target_arch: string;
767 v8_no_strict_aliasing: number;
768 v8_use_snapshot: boolean;
769 visibility: string;
770 };
771 };
772 kill(pid: number, signal?: string | number): void;
773 pid: number;
774 ppid: number;
775 title: string;
776 arch: string;
777 platform: Platform;
778 mainModule?: NodeModule;
779 memoryUsage(): MemoryUsage;
780 cpuUsage(previousValue?: CpuUsage): CpuUsage;
781 nextTick(callback: Function, ...args: any[]): void;
782 umask(mask?: number): number;
783 uptime(): number;
784 hrtime(time?: [number, number]): [number, number];
785 domain: Domain;
786
787 // Worker
788 send?(message: any, sendHandle?: any): void;
789 disconnect(): void;
790 connected: boolean;
791
792 /**
793 * EventEmitter
794 * 1. beforeExit
795 * 2. disconnect
796 * 3. exit
797 * 4. message
798 * 5. rejectionHandled
799 * 6. uncaughtException
800 * 7. unhandledRejection
801 * 8. warning
802 * 9. message
803 * 10. <All OS Signals>
804 * 11. newListener/removeListener inherited from EventEmitter
805 */
806 addListener(event: "beforeExit", listener: BeforeExitListener): this;
807 addListener(event: "disconnect", listener: DisconnectListener): this;
808 addListener(event: "exit", listener: ExitListener): this;
809 addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
810 addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
811 addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
812 addListener(event: "warning", listener: WarningListener): this;
813 addListener(event: "message", listener: MessageListener): this;
814 addListener(event: Signals, listener: SignalsListener): this;
815 addListener(event: "newListener", listener: NewListenerListener): this;
816 addListener(event: "removeListener", listener: RemoveListenerListener): this;
817
818 emit(event: "beforeExit", code: number): boolean;
819 emit(event: "disconnect"): boolean;
820 emit(event: "exit", code: number): boolean;
821 emit(event: "rejectionHandled", promise: Promise<any>): boolean;
822 emit(event: "uncaughtException", error: Error): boolean;
823 emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean;
824 emit(event: "warning", warning: Error): boolean;
825 emit(event: "message", message: any, sendHandle: any): this;
826 emit(event: Signals): boolean;
827 emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
828 emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
829
830 on(event: "beforeExit", listener: BeforeExitListener): this;
831 on(event: "disconnect", listener: DisconnectListener): this;
832 on(event: "exit", listener: ExitListener): this;
833 on(event: "rejectionHandled", listener: RejectionHandledListener): this;
834 on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
835 on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
836 on(event: "warning", listener: WarningListener): this;
837 on(event: "message", listener: MessageListener): this;
838 on(event: Signals, listener: SignalsListener): this;
839 on(event: "newListener", listener: NewListenerListener): this;
840 on(event: "removeListener", listener: RemoveListenerListener): this;
841
842 once(event: "beforeExit", listener: BeforeExitListener): this;
843 once(event: "disconnect", listener: DisconnectListener): this;
844 once(event: "exit", listener: ExitListener): this;
845 once(event: "rejectionHandled", listener: RejectionHandledListener): this;
846 once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
847 once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
848 once(event: "warning", listener: WarningListener): this;
849 once(event: "message", listener: MessageListener): this;
850 once(event: Signals, listener: SignalsListener): this;
851 once(event: "newListener", listener: NewListenerListener): this;
852 once(event: "removeListener", listener: RemoveListenerListener): this;
853
854 prependListener(event: "beforeExit", listener: BeforeExitListener): this;
855 prependListener(event: "disconnect", listener: DisconnectListener): this;
856 prependListener(event: "exit", listener: ExitListener): this;
857 prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
858 prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
859 prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
860 prependListener(event: "warning", listener: WarningListener): this;
861 prependListener(event: "message", listener: MessageListener): this;
862 prependListener(event: Signals, listener: SignalsListener): this;
863 prependListener(event: "newListener", listener: NewListenerListener): this;
864 prependListener(event: "removeListener", listener: RemoveListenerListener): this;
865
866 prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
867 prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
868 prependOnceListener(event: "exit", listener: ExitListener): this;
869 prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
870 prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
871 prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
872 prependOnceListener(event: "warning", listener: WarningListener): this;
873 prependOnceListener(event: "message", listener: MessageListener): this;
874 prependOnceListener(event: Signals, listener: SignalsListener): this;
875 prependOnceListener(event: "newListener", listener: NewListenerListener): this;
876 prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
877
878 listeners(event: "beforeExit"): BeforeExitListener[];
879 listeners(event: "disconnect"): DisconnectListener[];
880 listeners(event: "exit"): ExitListener[];
881 listeners(event: "rejectionHandled"): RejectionHandledListener[];
882 listeners(event: "uncaughtException"): UncaughtExceptionListener[];
883 listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
884 listeners(event: "warning"): WarningListener[];
885 listeners(event: "message"): MessageListener[];
886 listeners(event: Signals): SignalsListener[];
887 listeners(event: "newListener"): NewListenerListener[];
888 listeners(event: "removeListener"): RemoveListenerListener[];
889 }
890
891 export interface Global {
892 Array: typeof Array;
893 ArrayBuffer: typeof ArrayBuffer;
894 Boolean: typeof Boolean;
895 Buffer: typeof Buffer;
896 DataView: typeof DataView;
897 Date: typeof Date;
898 Error: typeof Error;
899 EvalError: typeof EvalError;
900 Float32Array: typeof Float32Array;
901 Float64Array: typeof Float64Array;
902 Function: typeof Function;
903 GLOBAL: Global;
904 Infinity: typeof Infinity;
905 Int16Array: typeof Int16Array;
906 Int32Array: typeof Int32Array;
907 Int8Array: typeof Int8Array;
908 Intl: typeof Intl;
909 JSON: typeof JSON;
910 Map: MapConstructor;
911 Math: typeof Math;
912 NaN: typeof NaN;
913 Number: typeof Number;
914 Object: typeof Object;
915 Promise: Function;
916 RangeError: typeof RangeError;
917 ReferenceError: typeof ReferenceError;
918 RegExp: typeof RegExp;
919 Set: SetConstructor;
920 String: typeof String;
921 Symbol: Function;
922 SyntaxError: typeof SyntaxError;
923 TypeError: typeof TypeError;
924 URIError: typeof URIError;
925 Uint16Array: typeof Uint16Array;
926 Uint32Array: typeof Uint32Array;
927 Uint8Array: typeof Uint8Array;
928 Uint8ClampedArray: Function;
929 WeakMap: WeakMapConstructor;
930 WeakSet: WeakSetConstructor;
931 clearImmediate: (immediateId: any) => void;
932 clearInterval: (intervalId: NodeJS.Timer) => void;
933 clearTimeout: (timeoutId: NodeJS.Timer) => void;
934 console: typeof console;
935 decodeURI: typeof decodeURI;
936 decodeURIComponent: typeof decodeURIComponent;
937 encodeURI: typeof encodeURI;
938 encodeURIComponent: typeof encodeURIComponent;
939 escape: (str: string) => string;
940 eval: typeof eval;
941 global: Global;
942 isFinite: typeof isFinite;
943 isNaN: typeof isNaN;
944 parseFloat: typeof parseFloat;
945 parseInt: typeof parseInt;
946 process: Process;
947 root: Global;
948 setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
949 setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
950 setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
951 undefined: typeof undefined;
952 unescape: (str: string) => string;
953 gc: () => void;
954 v8debug?: any;
955 }
956
957 export interface Timer {
958 ref(): void;
959 unref(): void;
960 }
961
962 class Module {
963 static runMain(): void;
964 static wrap(code: string): string;
965 static builtinModules: string[];
966
967 static Module: typeof Module;
968
969 exports: any;
970 require: NodeRequireFunction;
971 id: string;
972 filename: string;
973 loaded: boolean;
974 parent: Module | null;
975 children: Module[];
976 paths: string[];
977
978 constructor(id: string, parent?: Module);
979 }
980
981 type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
982}
983
984interface IterableIterator<T> { }
985
986/************************************************
987* *
988* MODULES *
989* *
990************************************************/
991declare module "buffer" {
992 export var INSPECT_MAX_BYTES: number;
993 var BuffType: typeof Buffer;
994 var SlowBuffType: typeof SlowBuffer;
995 export { BuffType as Buffer, SlowBuffType as SlowBuffer };
996}
997
998declare module "querystring" {
999 export interface StringifyOptions {
1000 encodeURIComponent?: Function;
1001 }
1002
1003 export interface ParseOptions {
1004 maxKeys?: number;
1005 decodeURIComponent?: Function;
1006 }
1007
1008 interface ParsedUrlQuery { [key: string]: string | string[] | undefined; }
1009
1010 export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
1011 export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): ParsedUrlQuery;
1012 export function parse<T extends {}>(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
1013 export function escape(str: string): string;
1014 export function unescape(str: string): string;
1015}
1016
1017declare module "events" {
1018 class internal extends NodeJS.EventEmitter { }
1019
1020 namespace internal {
1021 export class EventEmitter extends internal {
1022 /** @deprecated since v4.0.0 */
1023 static listenerCount(emitter: EventEmitter, event: string | symbol): number;
1024 static defaultMaxListeners: number;
1025
1026 addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1027 on(event: string | symbol, listener: (...args: any[]) => void): this;
1028 once(event: string | symbol, listener: (...args: any[]) => void): this;
1029 prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1030 prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1031 removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
1032 off(event: string | symbol, listener: (...args: any[]) => void): this;
1033 removeAllListeners(event?: string | symbol): this;
1034 setMaxListeners(n: number): this;
1035 getMaxListeners(): number;
1036 listeners(event: string | symbol): Function[];
1037 rawListeners(event: string | symbol): Function[];
1038 emit(event: string | symbol, ...args: any[]): boolean;
1039 eventNames(): Array<string | symbol>;
1040 listenerCount(type: string | symbol): number;
1041 }
1042 }
1043
1044 export = internal;
1045}
1046
1047declare module "http" {
1048 import * as events from "events";
1049 import * as net from "net";
1050 import * as stream from "stream";
1051 import { URL } from "url";
1052
1053 // incoming headers will never contain number
1054 export interface IncomingHttpHeaders {
1055 'accept'?: string;
1056 'access-control-allow-origin'?: string;
1057 'access-control-allow-credentials'?: string;
1058 'access-control-expose-headers'?: string;
1059 'access-control-max-age'?: string;
1060 'access-control-allow-methods'?: string;
1061 'access-control-allow-headers'?: string;
1062 'accept-patch'?: string;
1063 'accept-ranges'?: string;
1064 'authorization'?: string;
1065 'age'?: string;
1066 'allow'?: string;
1067 'alt-svc'?: string;
1068 'cache-control'?: string;
1069 'connection'?: string;
1070 'content-disposition'?: string;
1071 'content-encoding'?: string;
1072 'content-language'?: string;
1073 'content-length'?: string;
1074 'content-location'?: string;
1075 'content-range'?: string;
1076 'content-type'?: string;
1077 'date'?: string;
1078 'expires'?: string;
1079 'host'?: string;
1080 'last-modified'?: string;
1081 'location'?: string;
1082 'pragma'?: string;
1083 'proxy-authenticate'?: string;
1084 'public-key-pins'?: string;
1085 'retry-after'?: string;
1086 'set-cookie'?: string[];
1087 'strict-transport-security'?: string;
1088 'trailer'?: string;
1089 'transfer-encoding'?: string;
1090 'tk'?: string;
1091 'upgrade'?: string;
1092 'vary'?: string;
1093 'via'?: string;
1094 'warning'?: string;
1095 'www-authenticate'?: string;
1096 [header: string]: string | string[] | undefined;
1097 }
1098
1099 // outgoing headers allows numbers (as they are converted internally to strings)
1100 export interface OutgoingHttpHeaders {
1101 [header: string]: number | string | string[] | undefined;
1102 }
1103
1104 export interface ClientRequestArgs {
1105 protocol?: string;
1106 host?: string;
1107 hostname?: string;
1108 family?: number;
1109 port?: number | string;
1110 defaultPort?: number | string;
1111 localAddress?: string;
1112 socketPath?: string;
1113 method?: string;
1114 path?: string;
1115 headers?: OutgoingHttpHeaders;
1116 auth?: string;
1117 agent?: Agent | boolean;
1118 _defaultAgent?: Agent;
1119 timeout?: number;
1120 // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
1121 createConnection?: (options: ClientRequestArgs, oncreate: (err: Error, socket: net.Socket) => void) => net.Socket;
1122 }
1123
1124 export class Server extends net.Server {
1125 constructor(requestListener?: (req: IncomingMessage, res: ServerResponse) => void);
1126
1127 setTimeout(msecs?: number, callback?: () => void): this;
1128 setTimeout(callback: () => void): this;
1129 maxHeadersCount: number;
1130 timeout: number;
1131 keepAliveTimeout: number;
1132 }
1133 /**
1134 * @deprecated Use IncomingMessage
1135 */
1136 export class ServerRequest extends IncomingMessage {
1137 connection: net.Socket;
1138 }
1139
1140 // https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
1141 export class OutgoingMessage extends stream.Writable {
1142 upgrading: boolean;
1143 chunkedEncoding: boolean;
1144 shouldKeepAlive: boolean;
1145 useChunkedEncodingByDefault: boolean;
1146 sendDate: boolean;
1147 finished: boolean;
1148 headersSent: boolean;
1149 connection: net.Socket;
1150
1151 constructor();
1152
1153 setTimeout(msecs: number, callback?: () => void): this;
1154 destroy(error: Error): void;
1155 setHeader(name: string, value: number | string | string[]): void;
1156 getHeader(name: string): number | string | string[] | undefined;
1157 getHeaders(): OutgoingHttpHeaders;
1158 getHeaderNames(): string[];
1159 hasHeader(name: string): boolean;
1160 removeHeader(name: string): void;
1161 addTrailers(headers: OutgoingHttpHeaders | Array<[string, string]>): void;
1162 flushHeaders(): void;
1163 }
1164
1165 // https://github.com/nodejs/node/blob/master/lib/_http_server.js#L108-L256
1166 export class ServerResponse extends OutgoingMessage {
1167 statusCode: number;
1168 statusMessage: string;
1169
1170 constructor(req: IncomingMessage);
1171
1172 assignSocket(socket: net.Socket): void;
1173 detachSocket(socket: net.Socket): void;
1174 // https://github.com/nodejs/node/blob/master/test/parallel/test-http-write-callbacks.js#L53
1175 // no args in writeContinue callback
1176 writeContinue(callback?: () => void): void;
1177 writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void;
1178 writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
1179 }
1180
1181 // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L77
1182 export class ClientRequest extends OutgoingMessage {
1183 connection: net.Socket;
1184 socket: net.Socket;
1185 aborted: number;
1186
1187 constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
1188
1189 abort(): void;
1190 onSocket(socket: net.Socket): void;
1191 setTimeout(timeout: number, callback?: () => void): this;
1192 setNoDelay(noDelay?: boolean): void;
1193 setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
1194 }
1195
1196 export class IncomingMessage extends stream.Readable {
1197 constructor(socket: net.Socket);
1198
1199 httpVersion: string;
1200 httpVersionMajor: number;
1201 httpVersionMinor: number;
1202 connection: net.Socket;
1203 headers: IncomingHttpHeaders;
1204 rawHeaders: string[];
1205 trailers: { [key: string]: string | undefined };
1206 rawTrailers: string[];
1207 setTimeout(msecs: number, callback: () => void): this;
1208 /**
1209 * Only valid for request obtained from http.Server.
1210 */
1211 method?: string;
1212 /**
1213 * Only valid for request obtained from http.Server.
1214 */
1215 url?: string;
1216 /**
1217 * Only valid for response obtained from http.ClientRequest.
1218 */
1219 statusCode?: number;
1220 /**
1221 * Only valid for response obtained from http.ClientRequest.
1222 */
1223 statusMessage?: string;
1224 socket: net.Socket;
1225 destroy(error?: Error): void;
1226 }
1227
1228 /**
1229 * @deprecated Use IncomingMessage
1230 */
1231 export class ClientResponse extends IncomingMessage { }
1232
1233 export interface AgentOptions {
1234 /**
1235 * Keep sockets around in a pool to be used by other requests in the future. Default = false
1236 */
1237 keepAlive?: boolean;
1238 /**
1239 * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
1240 * Only relevant if keepAlive is set to true.
1241 */
1242 keepAliveMsecs?: number;
1243 /**
1244 * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1245 */
1246 maxSockets?: number;
1247 /**
1248 * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
1249 */
1250 maxFreeSockets?: number;
1251 }
1252
1253 export class Agent {
1254 maxFreeSockets: number;
1255 maxSockets: number;
1256 sockets: any;
1257 requests: any;
1258
1259 constructor(opts?: AgentOptions);
1260
1261 /**
1262 * Destroy any sockets that are currently in use by the agent.
1263 * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
1264 * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
1265 * sockets may hang open for quite a long time before the server terminates them.
1266 */
1267 destroy(): void;
1268 }
1269
1270 export var METHODS: string[];
1271
1272 export var STATUS_CODES: {
1273 [errorCode: number]: string | undefined;
1274 [errorCode: string]: string | undefined;
1275 };
1276
1277 export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
1278 export function createClient(port?: number, host?: string): any;
1279
1280 // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
1281 // create interface RequestOptions would make the naming more clear to developers
1282 export interface RequestOptions extends ClientRequestArgs { }
1283 export function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1284 export function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1285 export var globalAgent: Agent;
1286}
1287
1288declare module "cluster" {
1289 import * as child from "child_process";
1290 import * as events from "events";
1291 import * as net from "net";
1292
1293 // interfaces
1294 export interface ClusterSettings {
1295 execArgv?: string[]; // default: process.execArgv
1296 exec?: string;
1297 args?: string[];
1298 silent?: boolean;
1299 stdio?: any[];
1300 uid?: number;
1301 gid?: number;
1302 inspectPort?: number | (() => number);
1303 }
1304
1305 export interface Address {
1306 address: string;
1307 port: number;
1308 addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
1309 }
1310
1311 export class Worker extends events.EventEmitter {
1312 id: number;
1313 process: child.ChildProcess;
1314 suicide: boolean;
1315 send(message: any, sendHandle?: any, callback?: (error: Error) => void): boolean;
1316 kill(signal?: string): void;
1317 destroy(signal?: string): void;
1318 disconnect(): void;
1319 isConnected(): boolean;
1320 isDead(): boolean;
1321 exitedAfterDisconnect: boolean;
1322
1323 /**
1324 * events.EventEmitter
1325 * 1. disconnect
1326 * 2. error
1327 * 3. exit
1328 * 4. listening
1329 * 5. message
1330 * 6. online
1331 */
1332 addListener(event: string, listener: (...args: any[]) => void): this;
1333 addListener(event: "disconnect", listener: () => void): this;
1334 addListener(event: "error", listener: (error: Error) => void): this;
1335 addListener(event: "exit", listener: (code: number, signal: string) => void): this;
1336 addListener(event: "listening", listener: (address: Address) => void): this;
1337 addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1338 addListener(event: "online", listener: () => void): this;
1339
1340 emit(event: string | symbol, ...args: any[]): boolean;
1341 emit(event: "disconnect"): boolean;
1342 emit(event: "error", error: Error): boolean;
1343 emit(event: "exit", code: number, signal: string): boolean;
1344 emit(event: "listening", address: Address): boolean;
1345 emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
1346 emit(event: "online"): boolean;
1347
1348 on(event: string, listener: (...args: any[]) => void): this;
1349 on(event: "disconnect", listener: () => void): this;
1350 on(event: "error", listener: (error: Error) => void): this;
1351 on(event: "exit", listener: (code: number, signal: string) => void): this;
1352 on(event: "listening", listener: (address: Address) => void): this;
1353 on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1354 on(event: "online", listener: () => void): this;
1355
1356 once(event: string, listener: (...args: any[]) => void): this;
1357 once(event: "disconnect", listener: () => void): this;
1358 once(event: "error", listener: (error: Error) => void): this;
1359 once(event: "exit", listener: (code: number, signal: string) => void): this;
1360 once(event: "listening", listener: (address: Address) => void): this;
1361 once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1362 once(event: "online", listener: () => void): this;
1363
1364 prependListener(event: string, listener: (...args: any[]) => void): this;
1365 prependListener(event: "disconnect", listener: () => void): this;
1366 prependListener(event: "error", listener: (error: Error) => void): this;
1367 prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
1368 prependListener(event: "listening", listener: (address: Address) => void): this;
1369 prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1370 prependListener(event: "online", listener: () => void): this;
1371
1372 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
1373 prependOnceListener(event: "disconnect", listener: () => void): this;
1374 prependOnceListener(event: "error", listener: (error: Error) => void): this;
1375 prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
1376 prependOnceListener(event: "listening", listener: (address: Address) => void): this;
1377 prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1378 prependOnceListener(event: "online", listener: () => void): this;
1379 }
1380
1381 export interface Cluster extends events.EventEmitter {
1382 Worker: Worker;
1383 disconnect(callback?: Function): void;
1384 fork(env?: any): Worker;
1385 isMaster: boolean;
1386 isWorker: boolean;
1387 // TODO: cluster.schedulingPolicy
1388 settings: ClusterSettings;
1389 setupMaster(settings?: ClusterSettings): void;
1390 worker?: Worker;
1391 workers?: {
1392 [index: string]: Worker | undefined
1393 };
1394
1395 /**
1396 * events.EventEmitter
1397 * 1. disconnect
1398 * 2. exit
1399 * 3. fork
1400 * 4. listening
1401 * 5. message
1402 * 6. online
1403 * 7. setup
1404 */
1405 addListener(event: string, listener: (...args: any[]) => void): this;
1406 addListener(event: "disconnect", listener: (worker: Worker) => void): this;
1407 addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
1408 addListener(event: "fork", listener: (worker: Worker) => void): this;
1409 addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
1410 addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1411 addListener(event: "online", listener: (worker: Worker) => void): this;
1412 addListener(event: "setup", listener: (settings: any) => void): this;
1413
1414 emit(event: string | symbol, ...args: any[]): boolean;
1415 emit(event: "disconnect", worker: Worker): boolean;
1416 emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
1417 emit(event: "fork", worker: Worker): boolean;
1418 emit(event: "listening", worker: Worker, address: Address): boolean;
1419 emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
1420 emit(event: "online", worker: Worker): boolean;
1421 emit(event: "setup", settings: any): boolean;
1422
1423 on(event: string, listener: (...args: any[]) => void): this;
1424 on(event: "disconnect", listener: (worker: Worker) => void): this;
1425 on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
1426 on(event: "fork", listener: (worker: Worker) => void): this;
1427 on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
1428 on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1429 on(event: "online", listener: (worker: Worker) => void): this;
1430 on(event: "setup", listener: (settings: any) => void): this;
1431
1432 once(event: string, listener: (...args: any[]) => void): this;
1433 once(event: "disconnect", listener: (worker: Worker) => void): this;
1434 once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
1435 once(event: "fork", listener: (worker: Worker) => void): this;
1436 once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
1437 once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1438 once(event: "online", listener: (worker: Worker) => void): this;
1439 once(event: "setup", listener: (settings: any) => void): this;
1440
1441 prependListener(event: string, listener: (...args: any[]) => void): this;
1442 prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
1443 prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
1444 prependListener(event: "fork", listener: (worker: Worker) => void): this;
1445 prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
1446 prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1447 prependListener(event: "online", listener: (worker: Worker) => void): this;
1448 prependListener(event: "setup", listener: (settings: any) => void): this;
1449
1450 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
1451 prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
1452 prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
1453 prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
1454 prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
1455 prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
1456 prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
1457 prependOnceListener(event: "setup", listener: (settings: any) => void): this;
1458 }
1459
1460 export function disconnect(callback?: Function): void;
1461 export function fork(env?: any): Worker;
1462 export var isMaster: boolean;
1463 export var isWorker: boolean;
1464 // TODO: cluster.schedulingPolicy
1465 export var settings: ClusterSettings;
1466 export function setupMaster(settings?: ClusterSettings): void;
1467 export var worker: Worker;
1468 export var workers: {
1469 [index: string]: Worker | undefined
1470 };
1471
1472 /**
1473 * events.EventEmitter
1474 * 1. disconnect
1475 * 2. exit
1476 * 3. fork
1477 * 4. listening
1478 * 5. message
1479 * 6. online
1480 * 7. setup
1481 */
1482 export function addListener(event: string, listener: (...args: any[]) => void): Cluster;
1483 export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
1484 export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
1485 export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
1486 export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
1487 export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
1488 export function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
1489 export function addListener(event: "setup", listener: (settings: any) => void): Cluster;
1490
1491 export function emit(event: string | symbol, ...args: any[]): boolean;
1492 export function emit(event: "disconnect", worker: Worker): boolean;
1493 export function emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
1494 export function emit(event: "fork", worker: Worker): boolean;
1495 export function emit(event: "listening", worker: Worker, address: Address): boolean;
1496 export function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
1497 export function emit(event: "online", worker: Worker): boolean;
1498 export function emit(event: "setup", settings: any): boolean;
1499
1500 export function on(event: string, listener: (...args: any[]) => void): Cluster;
1501 export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
1502 export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
1503 export function on(event: "fork", listener: (worker: Worker) => void): Cluster;
1504 export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
1505 export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
1506 export function on(event: "online", listener: (worker: Worker) => void): Cluster;
1507 export function on(event: "setup", listener: (settings: any) => void): Cluster;
1508
1509 export function once(event: string, listener: (...args: any[]) => void): Cluster;
1510 export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
1511 export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
1512 export function once(event: "fork", listener: (worker: Worker) => void): Cluster;
1513 export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
1514 export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
1515 export function once(event: "online", listener: (worker: Worker) => void): Cluster;
1516 export function once(event: "setup", listener: (settings: any) => void): Cluster;
1517
1518 export function removeListener(event: string, listener: (...args: any[]) => void): Cluster;
1519 export function removeAllListeners(event?: string): Cluster;
1520 export function setMaxListeners(n: number): Cluster;
1521 export function getMaxListeners(): number;
1522 export function listeners(event: string): Function[];
1523 export function listenerCount(type: string): number;
1524
1525 export function prependListener(event: string, listener: (...args: any[]) => void): Cluster;
1526 export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
1527 export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
1528 export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
1529 export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
1530 export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
1531 export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
1532 export function prependListener(event: "setup", listener: (settings: any) => void): Cluster;
1533
1534 export function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster;
1535 export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
1536 export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
1537 export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
1538 export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
1539 export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
1540 export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
1541 export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster;
1542
1543 export function eventNames(): string[];
1544}
1545
1546declare module "zlib" {
1547 import * as stream from "stream";
1548
1549 export interface ZlibOptions {
1550 flush?: number; // default: zlib.constants.Z_NO_FLUSH
1551 finishFlush?: number; // default: zlib.constants.Z_FINISH
1552 chunkSize?: number; // default: 16*1024
1553 windowBits?: number;
1554 level?: number; // compression only
1555 memLevel?: number; // compression only
1556 strategy?: number; // compression only
1557 dictionary?: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
1558 }
1559
1560 export interface Zlib {
1561 readonly bytesRead: number;
1562 close(callback?: () => void): void;
1563 flush(kind?: number | (() => void), callback?: () => void): void;
1564 }
1565
1566 export interface ZlibParams {
1567 params(level: number, strategy: number, callback: () => void): void;
1568 }
1569
1570 export interface ZlibReset {
1571 reset(): void;
1572 }
1573
1574 export interface Gzip extends stream.Transform, Zlib { }
1575 export interface Gunzip extends stream.Transform, Zlib { }
1576 export interface Deflate extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
1577 export interface Inflate extends stream.Transform, Zlib, ZlibReset { }
1578 export interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams { }
1579 export interface InflateRaw extends stream.Transform, Zlib, ZlibReset { }
1580 export interface Unzip extends stream.Transform, Zlib { }
1581
1582 export function createGzip(options?: ZlibOptions): Gzip;
1583 export function createGunzip(options?: ZlibOptions): Gunzip;
1584 export function createDeflate(options?: ZlibOptions): Deflate;
1585 export function createInflate(options?: ZlibOptions): Inflate;
1586 export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
1587 export function createInflateRaw(options?: ZlibOptions): InflateRaw;
1588 export function createUnzip(options?: ZlibOptions): Unzip;
1589
1590 type InputType = string | Buffer | DataView | ArrayBuffer | NodeJS.TypedArray;
1591 export function deflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1592 export function deflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1593 export function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
1594 export function deflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1595 export function deflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1596 export function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
1597 export function gzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1598 export function gzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1599 export function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
1600 export function gunzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1601 export function gunzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1602 export function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
1603 export function inflate(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1604 export function inflate(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1605 export function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
1606 export function inflateRaw(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1607 export function inflateRaw(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1608 export function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
1609 export function unzip(buf: InputType, callback: (error: Error | null, result: Buffer) => void): void;
1610 export function unzip(buf: InputType, options: ZlibOptions, callback: (error: Error | null, result: Buffer) => void): void;
1611 export function unzipSync(buf: InputType, options?: ZlibOptions): Buffer;
1612
1613 export namespace constants {
1614 // Allowed flush values.
1615
1616 export const Z_NO_FLUSH: number;
1617 export const Z_PARTIAL_FLUSH: number;
1618 export const Z_SYNC_FLUSH: number;
1619 export const Z_FULL_FLUSH: number;
1620 export const Z_FINISH: number;
1621 export const Z_BLOCK: number;
1622 export const Z_TREES: number;
1623
1624 // Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events.
1625
1626 export const Z_OK: number;
1627 export const Z_STREAM_END: number;
1628 export const Z_NEED_DICT: number;
1629 export const Z_ERRNO: number;
1630 export const Z_STREAM_ERROR: number;
1631 export const Z_DATA_ERROR: number;
1632 export const Z_MEM_ERROR: number;
1633 export const Z_BUF_ERROR: number;
1634 export const Z_VERSION_ERROR: number;
1635
1636 // Compression levels.
1637
1638 export const Z_NO_COMPRESSION: number;
1639 export const Z_BEST_SPEED: number;
1640 export const Z_BEST_COMPRESSION: number;
1641 export const Z_DEFAULT_COMPRESSION: number;
1642
1643 // Compression strategy.
1644
1645 export const Z_FILTERED: number;
1646 export const Z_HUFFMAN_ONLY: number;
1647 export const Z_RLE: number;
1648 export const Z_FIXED: number;
1649 export const Z_DEFAULT_STRATEGY: number;
1650 }
1651
1652 // Constants
1653 export var Z_NO_FLUSH: number;
1654 export var Z_PARTIAL_FLUSH: number;
1655 export var Z_SYNC_FLUSH: number;
1656 export var Z_FULL_FLUSH: number;
1657 export var Z_FINISH: number;
1658 export var Z_BLOCK: number;
1659 export var Z_TREES: number;
1660 export var Z_OK: number;
1661 export var Z_STREAM_END: number;
1662 export var Z_NEED_DICT: number;
1663 export var Z_ERRNO: number;
1664 export var Z_STREAM_ERROR: number;
1665 export var Z_DATA_ERROR: number;
1666 export var Z_MEM_ERROR: number;
1667 export var Z_BUF_ERROR: number;
1668 export var Z_VERSION_ERROR: number;
1669 export var Z_NO_COMPRESSION: number;
1670 export var Z_BEST_SPEED: number;
1671 export var Z_BEST_COMPRESSION: number;
1672 export var Z_DEFAULT_COMPRESSION: number;
1673 export var Z_FILTERED: number;
1674 export var Z_HUFFMAN_ONLY: number;
1675 export var Z_RLE: number;
1676 export var Z_FIXED: number;
1677 export var Z_DEFAULT_STRATEGY: number;
1678 export var Z_BINARY: number;
1679 export var Z_TEXT: number;
1680 export var Z_ASCII: number;
1681 export var Z_UNKNOWN: number;
1682 export var Z_DEFLATED: number;
1683}
1684
1685declare module "os" {
1686 export interface CpuInfo {
1687 model: string;
1688 speed: number;
1689 times: {
1690 user: number;
1691 nice: number;
1692 sys: number;
1693 idle: number;
1694 irq: number;
1695 };
1696 }
1697
1698 export interface NetworkInterfaceBase {
1699 address: string;
1700 netmask: string;
1701 mac: string;
1702 internal: boolean;
1703 }
1704
1705 export interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
1706 family: "IPv4";
1707 }
1708
1709 export interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
1710 family: "IPv6";
1711 scopeid: number;
1712 }
1713
1714 export type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
1715
1716 export function hostname(): string;
1717 export function loadavg(): number[];
1718 export function uptime(): number;
1719 export function freemem(): number;
1720 export function totalmem(): number;
1721 export function cpus(): CpuInfo[];
1722 export function type(): string;
1723 export function release(): string;
1724 export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
1725 export function homedir(): string;
1726 export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string };
1727 export var constants: {
1728 UV_UDP_REUSEADDR: number,
1729 signals: {
1730 SIGHUP: number;
1731 SIGINT: number;
1732 SIGQUIT: number;
1733 SIGILL: number;
1734 SIGTRAP: number;
1735 SIGABRT: number;
1736 SIGIOT: number;
1737 SIGBUS: number;
1738 SIGFPE: number;
1739 SIGKILL: number;
1740 SIGUSR1: number;
1741 SIGSEGV: number;
1742 SIGUSR2: number;
1743 SIGPIPE: number;
1744 SIGALRM: number;
1745 SIGTERM: number;
1746 SIGCHLD: number;
1747 SIGSTKFLT: number;
1748 SIGCONT: number;
1749 SIGSTOP: number;
1750 SIGTSTP: number;
1751 SIGTTIN: number;
1752 SIGTTOU: number;
1753 SIGURG: number;
1754 SIGXCPU: number;
1755 SIGXFSZ: number;
1756 SIGVTALRM: number;
1757 SIGPROF: number;
1758 SIGWINCH: number;
1759 SIGIO: number;
1760 SIGPOLL: number;
1761 SIGPWR: number;
1762 SIGSYS: number;
1763 SIGUNUSED: number;
1764 },
1765 errno: {
1766 E2BIG: number;
1767 EACCES: number;
1768 EADDRINUSE: number;
1769 EADDRNOTAVAIL: number;
1770 EAFNOSUPPORT: number;
1771 EAGAIN: number;
1772 EALREADY: number;
1773 EBADF: number;
1774 EBADMSG: number;
1775 EBUSY: number;
1776 ECANCELED: number;
1777 ECHILD: number;
1778 ECONNABORTED: number;
1779 ECONNREFUSED: number;
1780 ECONNRESET: number;
1781 EDEADLK: number;
1782 EDESTADDRREQ: number;
1783 EDOM: number;
1784 EDQUOT: number;
1785 EEXIST: number;
1786 EFAULT: number;
1787 EFBIG: number;
1788 EHOSTUNREACH: number;
1789 EIDRM: number;
1790 EILSEQ: number;
1791 EINPROGRESS: number;
1792 EINTR: number;
1793 EINVAL: number;
1794 EIO: number;
1795 EISCONN: number;
1796 EISDIR: number;
1797 ELOOP: number;
1798 EMFILE: number;
1799 EMLINK: number;
1800 EMSGSIZE: number;
1801 EMULTIHOP: number;
1802 ENAMETOOLONG: number;
1803 ENETDOWN: number;
1804 ENETRESET: number;
1805 ENETUNREACH: number;
1806 ENFILE: number;
1807 ENOBUFS: number;
1808 ENODATA: number;
1809 ENODEV: number;
1810 ENOENT: number;
1811 ENOEXEC: number;
1812 ENOLCK: number;
1813 ENOLINK: number;
1814 ENOMEM: number;
1815 ENOMSG: number;
1816 ENOPROTOOPT: number;
1817 ENOSPC: number;
1818 ENOSR: number;
1819 ENOSTR: number;
1820 ENOSYS: number;
1821 ENOTCONN: number;
1822 ENOTDIR: number;
1823 ENOTEMPTY: number;
1824 ENOTSOCK: number;
1825 ENOTSUP: number;
1826 ENOTTY: number;
1827 ENXIO: number;
1828 EOPNOTSUPP: number;
1829 EOVERFLOW: number;
1830 EPERM: number;
1831 EPIPE: number;
1832 EPROTO: number;
1833 EPROTONOSUPPORT: number;
1834 EPROTOTYPE: number;
1835 ERANGE: number;
1836 EROFS: number;
1837 ESPIPE: number;
1838 ESRCH: number;
1839 ESTALE: number;
1840 ETIME: number;
1841 ETIMEDOUT: number;
1842 ETXTBSY: number;
1843 EWOULDBLOCK: number;
1844 EXDEV: number;
1845 },
1846 };
1847 export function arch(): string;
1848 export function platform(): NodeJS.Platform;
1849 export function tmpdir(): string;
1850 export const EOL: string;
1851 export function endianness(): "BE" | "LE";
1852}
1853
1854declare module "https" {
1855 import * as tls from "tls";
1856 import * as events from "events";
1857 import * as http from "http";
1858 import { URL } from "url";
1859
1860 export type ServerOptions = tls.SecureContextOptions & tls.TlsOptions;
1861
1862 export type RequestOptions = http.RequestOptions & tls.SecureContextOptions & {
1863 rejectUnauthorized?: boolean; // Defaults to true
1864 servername?: string; // SNI TLS Extension
1865 };
1866
1867 export interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
1868 rejectUnauthorized?: boolean;
1869 maxCachedSessions?: number;
1870 }
1871
1872 export class Agent extends http.Agent {
1873 constructor(options?: AgentOptions);
1874 options: AgentOptions;
1875 }
1876
1877 export class Server extends tls.Server {
1878 setTimeout(callback: () => void): this;
1879 setTimeout(msecs?: number, callback?: () => void): this;
1880 timeout: number;
1881 keepAliveTimeout: number;
1882 }
1883
1884 export function createServer(options: ServerOptions, requestListener?: (req: http.IncomingMessage, res: http.ServerResponse) => void): Server;
1885 export function request(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1886 export function get(options: RequestOptions | string | URL, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
1887 export var globalAgent: Agent;
1888}
1889
1890declare module "punycode" {
1891 export function decode(string: string): string;
1892 export function encode(string: string): string;
1893 export function toUnicode(domain: string): string;
1894 export function toASCII(domain: string): string;
1895 export var ucs2: ucs2;
1896 interface ucs2 {
1897 decode(string: string): number[];
1898 encode(codePoints: number[]): string;
1899 }
1900 export var version: any;
1901}
1902
1903declare module "repl" {
1904 import * as stream from "stream";
1905 import * as readline from "readline";
1906
1907 export interface ReplOptions {
1908 prompt?: string;
1909 input?: NodeJS.ReadableStream;
1910 output?: NodeJS.WritableStream;
1911 terminal?: boolean;
1912 eval?: Function;
1913 useColors?: boolean;
1914 useGlobal?: boolean;
1915 ignoreUndefined?: boolean;
1916 writer?: Function;
1917 completer?: Function;
1918 replMode?: any;
1919 breakEvalOnSigint?: any;
1920 }
1921
1922 export interface REPLServer extends readline.ReadLine {
1923 context: any;
1924 inputStream: NodeJS.ReadableStream;
1925 outputStream: NodeJS.WritableStream;
1926
1927 defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void;
1928 displayPrompt(preserveCursor?: boolean): void;
1929
1930 /**
1931 * events.EventEmitter
1932 * 1. exit
1933 * 2. reset
1934 */
1935
1936 addListener(event: string, listener: (...args: any[]) => void): this;
1937 addListener(event: "exit", listener: () => void): this;
1938 addListener(event: "reset", listener: (...args: any[]) => void): this;
1939
1940 emit(event: string | symbol, ...args: any[]): boolean;
1941 emit(event: "exit"): boolean;
1942 emit(event: "reset", context: any): boolean;
1943
1944 on(event: string, listener: (...args: any[]) => void): this;
1945 on(event: "exit", listener: () => void): this;
1946 on(event: "reset", listener: (...args: any[]) => void): this;
1947
1948 once(event: string, listener: (...args: any[]) => void): this;
1949 once(event: "exit", listener: () => void): this;
1950 once(event: "reset", listener: (...args: any[]) => void): this;
1951
1952 prependListener(event: string, listener: (...args: any[]) => void): this;
1953 prependListener(event: "exit", listener: () => void): this;
1954 prependListener(event: "reset", listener: (...args: any[]) => void): this;
1955
1956 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
1957 prependOnceListener(event: "exit", listener: () => void): this;
1958 prependOnceListener(event: "reset", listener: (...args: any[]) => void): this;
1959 }
1960
1961 export function start(options?: string | ReplOptions): REPLServer;
1962
1963 export class Recoverable extends SyntaxError {
1964 err: Error;
1965
1966 constructor(err: Error);
1967 }
1968}
1969
1970declare module "readline" {
1971 import * as events from "events";
1972 import * as stream from "stream";
1973
1974 export interface Key {
1975 sequence?: string;
1976 name?: string;
1977 ctrl?: boolean;
1978 meta?: boolean;
1979 shift?: boolean;
1980 }
1981
1982 export interface ReadLine extends events.EventEmitter {
1983 setPrompt(prompt: string): void;
1984 prompt(preserveCursor?: boolean): void;
1985 question(query: string, callback: (answer: string) => void): void;
1986 pause(): ReadLine;
1987 resume(): ReadLine;
1988 close(): void;
1989 write(data: string | Buffer, key?: Key): void;
1990
1991 /**
1992 * events.EventEmitter
1993 * 1. close
1994 * 2. line
1995 * 3. pause
1996 * 4. resume
1997 * 5. SIGCONT
1998 * 6. SIGINT
1999 * 7. SIGTSTP
2000 */
2001
2002 addListener(event: string, listener: (...args: any[]) => void): this;
2003 addListener(event: "close", listener: () => void): this;
2004 addListener(event: "line", listener: (input: any) => void): this;
2005 addListener(event: "pause", listener: () => void): this;
2006 addListener(event: "resume", listener: () => void): this;
2007 addListener(event: "SIGCONT", listener: () => void): this;
2008 addListener(event: "SIGINT", listener: () => void): this;
2009 addListener(event: "SIGTSTP", listener: () => void): this;
2010
2011 emit(event: string | symbol, ...args: any[]): boolean;
2012 emit(event: "close"): boolean;
2013 emit(event: "line", input: any): boolean;
2014 emit(event: "pause"): boolean;
2015 emit(event: "resume"): boolean;
2016 emit(event: "SIGCONT"): boolean;
2017 emit(event: "SIGINT"): boolean;
2018 emit(event: "SIGTSTP"): boolean;
2019
2020 on(event: string, listener: (...args: any[]) => void): this;
2021 on(event: "close", listener: () => void): this;
2022 on(event: "line", listener: (input: any) => void): this;
2023 on(event: "pause", listener: () => void): this;
2024 on(event: "resume", listener: () => void): this;
2025 on(event: "SIGCONT", listener: () => void): this;
2026 on(event: "SIGINT", listener: () => void): this;
2027 on(event: "SIGTSTP", listener: () => void): this;
2028
2029 once(event: string, listener: (...args: any[]) => void): this;
2030 once(event: "close", listener: () => void): this;
2031 once(event: "line", listener: (input: any) => void): this;
2032 once(event: "pause", listener: () => void): this;
2033 once(event: "resume", listener: () => void): this;
2034 once(event: "SIGCONT", listener: () => void): this;
2035 once(event: "SIGINT", listener: () => void): this;
2036 once(event: "SIGTSTP", listener: () => void): this;
2037
2038 prependListener(event: string, listener: (...args: any[]) => void): this;
2039 prependListener(event: "close", listener: () => void): this;
2040 prependListener(event: "line", listener: (input: any) => void): this;
2041 prependListener(event: "pause", listener: () => void): this;
2042 prependListener(event: "resume", listener: () => void): this;
2043 prependListener(event: "SIGCONT", listener: () => void): this;
2044 prependListener(event: "SIGINT", listener: () => void): this;
2045 prependListener(event: "SIGTSTP", listener: () => void): this;
2046
2047 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2048 prependOnceListener(event: "close", listener: () => void): this;
2049 prependOnceListener(event: "line", listener: (input: any) => void): this;
2050 prependOnceListener(event: "pause", listener: () => void): this;
2051 prependOnceListener(event: "resume", listener: () => void): this;
2052 prependOnceListener(event: "SIGCONT", listener: () => void): this;
2053 prependOnceListener(event: "SIGINT", listener: () => void): this;
2054 prependOnceListener(event: "SIGTSTP", listener: () => void): this;
2055 }
2056
2057 type Completer = (line: string) => CompleterResult;
2058 type AsyncCompleter = (line: string, callback: (err: any, result: CompleterResult) => void) => any;
2059
2060 export type CompleterResult = [string[], string];
2061
2062 export interface ReadLineOptions {
2063 input: NodeJS.ReadableStream;
2064 output?: NodeJS.WritableStream;
2065 completer?: Completer | AsyncCompleter;
2066 terminal?: boolean;
2067 historySize?: number;
2068 prompt?: string;
2069 crlfDelay?: number;
2070 removeHistoryDuplicates?: boolean;
2071 }
2072
2073 export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine;
2074 export function createInterface(options: ReadLineOptions): ReadLine;
2075
2076 export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number): void;
2077 export function emitKeypressEvents(stream: NodeJS.ReadableStream, interface?: ReadLine): void;
2078 export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
2079 export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
2080 export function clearScreenDown(stream: NodeJS.WritableStream): void;
2081}
2082
2083declare module "vm" {
2084 export interface Context { }
2085 export interface ScriptOptions {
2086 filename?: string;
2087 lineOffset?: number;
2088 columnOffset?: number;
2089 displayErrors?: boolean;
2090 timeout?: number;
2091 cachedData?: Buffer;
2092 produceCachedData?: boolean;
2093 }
2094 export interface RunningScriptOptions {
2095 filename?: string;
2096 lineOffset?: number;
2097 columnOffset?: number;
2098 displayErrors?: boolean;
2099 timeout?: number;
2100 }
2101 export class Script {
2102 constructor(code: string, options?: ScriptOptions);
2103 runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
2104 runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
2105 runInThisContext(options?: RunningScriptOptions): any;
2106 }
2107 export function createContext(sandbox?: Context): Context;
2108 export function isContext(sandbox: Context): boolean;
2109 export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions | string): any;
2110 /** @deprecated */
2111 export function runInDebugContext(code: string): any;
2112 export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions | string): any;
2113 export function runInThisContext(code: string, options?: RunningScriptOptions | string): any;
2114}
2115
2116declare module "child_process" {
2117 import * as events from "events";
2118 import * as stream from "stream";
2119 import * as net from "net";
2120
2121 export interface ChildProcess extends events.EventEmitter {
2122 stdin: stream.Writable;
2123 stdout: stream.Readable;
2124 stderr: stream.Readable;
2125 stdio: [stream.Writable, stream.Readable, stream.Readable];
2126 killed: boolean;
2127 pid: number;
2128 kill(signal?: string): void;
2129 send(message: any, callback?: (error: Error) => void): boolean;
2130 send(message: any, sendHandle?: net.Socket | net.Server, callback?: (error: Error) => void): boolean;
2131 send(message: any, sendHandle?: net.Socket | net.Server, options?: MessageOptions, callback?: (error: Error) => void): boolean;
2132 connected: boolean;
2133 disconnect(): void;
2134 unref(): void;
2135 ref(): void;
2136
2137 /**
2138 * events.EventEmitter
2139 * 1. close
2140 * 2. disconnect
2141 * 3. error
2142 * 4. exit
2143 * 5. message
2144 */
2145
2146 addListener(event: string, listener: (...args: any[]) => void): this;
2147 addListener(event: "close", listener: (code: number, signal: string) => void): this;
2148 addListener(event: "disconnect", listener: () => void): this;
2149 addListener(event: "error", listener: (err: Error) => void): this;
2150 addListener(event: "exit", listener: (code: number, signal: string) => void): this;
2151 addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
2152
2153 emit(event: string | symbol, ...args: any[]): boolean;
2154 emit(event: "close", code: number, signal: string): boolean;
2155 emit(event: "disconnect"): boolean;
2156 emit(event: "error", err: Error): boolean;
2157 emit(event: "exit", code: number, signal: string): boolean;
2158 emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean;
2159
2160 on(event: string, listener: (...args: any[]) => void): this;
2161 on(event: "close", listener: (code: number, signal: string) => void): this;
2162 on(event: "disconnect", listener: () => void): this;
2163 on(event: "error", listener: (err: Error) => void): this;
2164 on(event: "exit", listener: (code: number, signal: string) => void): this;
2165 on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
2166
2167 once(event: string, listener: (...args: any[]) => void): this;
2168 once(event: "close", listener: (code: number, signal: string) => void): this;
2169 once(event: "disconnect", listener: () => void): this;
2170 once(event: "error", listener: (err: Error) => void): this;
2171 once(event: "exit", listener: (code: number, signal: string) => void): this;
2172 once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
2173
2174 prependListener(event: string, listener: (...args: any[]) => void): this;
2175 prependListener(event: "close", listener: (code: number, signal: string) => void): this;
2176 prependListener(event: "disconnect", listener: () => void): this;
2177 prependListener(event: "error", listener: (err: Error) => void): this;
2178 prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
2179 prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
2180
2181 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2182 prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this;
2183 prependOnceListener(event: "disconnect", listener: () => void): this;
2184 prependOnceListener(event: "error", listener: (err: Error) => void): this;
2185 prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
2186 prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
2187 }
2188
2189 export interface MessageOptions {
2190 keepOpen?: boolean;
2191 }
2192
2193 export interface SpawnOptions {
2194 argv0?: string;
2195 cwd?: string;
2196 env?: any;
2197 stdio?: any;
2198 detached?: boolean;
2199 uid?: number;
2200 gid?: number;
2201 shell?: boolean | string;
2202 windowsVerbatimArguments?: boolean;
2203 windowsHide?: boolean;
2204 }
2205
2206 export function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
2207
2208 export interface ExecOptions {
2209 cwd?: string;
2210 env?: any;
2211 shell?: string;
2212 timeout?: number;
2213 maxBuffer?: number;
2214 killSignal?: string;
2215 uid?: number;
2216 gid?: number;
2217 windowsHide?: boolean;
2218 }
2219
2220 export interface ExecOptionsWithStringEncoding extends ExecOptions {
2221 encoding: BufferEncoding;
2222 }
2223
2224 export interface ExecOptionsWithBufferEncoding extends ExecOptions {
2225 encoding: string | null; // specify `null`.
2226 }
2227
2228 // no `options` definitely means stdout/stderr are `string`.
2229 export function exec(command: string, callback?: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2230
2231 // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
2232 export function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: Error | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
2233
2234 // `options` with well known `encoding` means stdout/stderr are definitely `string`.
2235 export function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2236
2237 // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
2238 // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
2239 export function exec(command: string, options: { encoding: string } & ExecOptions, callback?: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
2240
2241 // `options` without an `encoding` means stdout/stderr are definitely `string`.
2242 export function exec(command: string, options: ExecOptions, callback?: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2243
2244 // fallback if nothing else matches. Worst case is always `string | Buffer`.
2245 export function exec(command: string, options: ({ encoding?: string | null } & ExecOptions) | undefined | null, callback?: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
2246
2247 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2248 export namespace exec {
2249 export function __promisify__(command: string): Promise<{ stdout: string, stderr: string }>;
2250 export function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): Promise<{ stdout: Buffer, stderr: Buffer }>;
2251 export function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<{ stdout: string, stderr: string }>;
2252 export function __promisify__(command: string, options: ExecOptions): Promise<{ stdout: string, stderr: string }>;
2253 export function __promisify__(command: string, options?: ({ encoding?: string | null } & ExecOptions) | null): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
2254 }
2255
2256 export interface ExecFileOptions {
2257 cwd?: string;
2258 env?: any;
2259 timeout?: number;
2260 maxBuffer?: number;
2261 killSignal?: string;
2262 uid?: number;
2263 gid?: number;
2264 windowsHide?: boolean;
2265 windowsVerbatimArguments?: boolean;
2266 }
2267 export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
2268 encoding: BufferEncoding;
2269 }
2270 export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
2271 encoding: 'buffer' | null;
2272 }
2273 export interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
2274 encoding: string;
2275 }
2276
2277 export function execFile(file: string): ChildProcess;
2278 export function execFile(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
2279 export function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
2280 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
2281
2282 // no `options` definitely means stdout/stderr are `string`.
2283 export function execFile(file: string, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2284 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2285
2286 // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
2287 export function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: Error | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
2288 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithBufferEncoding, callback: (error: Error | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
2289
2290 // `options` with well known `encoding` means stdout/stderr are definitely `string`.
2291 export function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2292 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithStringEncoding, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2293
2294 // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
2295 // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
2296 export function execFile(file: string, options: ExecFileOptionsWithOtherEncoding, callback: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
2297 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithOtherEncoding, callback: (error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
2298
2299 // `options` without an `encoding` means stdout/stderr are definitely `string`.
2300 export function execFile(file: string, options: ExecFileOptions, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2301 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions, callback: (error: Error | null, stdout: string, stderr: string) => void): ChildProcess;
2302
2303 // fallback if nothing else matches. Worst case is always `string | Buffer`.
2304 export function execFile(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null, callback: ((error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null): ChildProcess;
2305 export function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null, callback: ((error: Error | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null): ChildProcess;
2306
2307 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2308 export namespace execFile {
2309 export function __promisify__(file: string): Promise<{ stdout: string, stderr: string }>;
2310 export function __promisify__(file: string, args: string[] | undefined | null): Promise<{ stdout: string, stderr: string }>;
2311 export function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): Promise<{ stdout: Buffer, stderr: Buffer }>;
2312 export function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithBufferEncoding): Promise<{ stdout: Buffer, stderr: Buffer }>;
2313 export function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): Promise<{ stdout: string, stderr: string }>;
2314 export function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithStringEncoding): Promise<{ stdout: string, stderr: string }>;
2315 export function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
2316 export function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithOtherEncoding): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
2317 export function __promisify__(file: string, options: ExecFileOptions): Promise<{ stdout: string, stderr: string }>;
2318 export function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptions): Promise<{ stdout: string, stderr: string }>;
2319 export function __promisify__(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
2320 export function __promisify__(file: string, args: string[] | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
2321 }
2322
2323 export interface ForkOptions {
2324 cwd?: string;
2325 env?: any;
2326 execPath?: string;
2327 execArgv?: string[];
2328 silent?: boolean;
2329 stdio?: any[];
2330 uid?: number;
2331 gid?: number;
2332 windowsVerbatimArguments?: boolean;
2333 }
2334 export function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
2335
2336 export interface SpawnSyncOptions {
2337 argv0?: string;
2338 cwd?: string;
2339 input?: string | Buffer;
2340 stdio?: any;
2341 env?: any;
2342 uid?: number;
2343 gid?: number;
2344 timeout?: number;
2345 killSignal?: string;
2346 maxBuffer?: number;
2347 encoding?: string;
2348 shell?: boolean | string;
2349 windowsHide?: boolean;
2350 windowsVerbatimArguments?: boolean;
2351 }
2352 export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
2353 encoding: BufferEncoding;
2354 }
2355 export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
2356 encoding: string; // specify `null`.
2357 }
2358 export interface SpawnSyncReturns<T> {
2359 pid: number;
2360 output: string[];
2361 stdout: T;
2362 stderr: T;
2363 status: number;
2364 signal: string;
2365 error: Error;
2366 }
2367 export function spawnSync(command: string): SpawnSyncReturns<Buffer>;
2368 export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
2369 export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
2370 export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
2371 export function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
2372 export function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
2373 export function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
2374
2375 export interface ExecSyncOptions {
2376 cwd?: string;
2377 input?: string | Buffer;
2378 stdio?: any;
2379 env?: any;
2380 shell?: string;
2381 uid?: number;
2382 gid?: number;
2383 timeout?: number;
2384 killSignal?: string;
2385 maxBuffer?: number;
2386 encoding?: string;
2387 windowsHide?: boolean;
2388 }
2389 export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
2390 encoding: BufferEncoding;
2391 }
2392 export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
2393 encoding: string; // specify `null`.
2394 }
2395 export function execSync(command: string): Buffer;
2396 export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
2397 export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
2398 export function execSync(command: string, options?: ExecSyncOptions): Buffer;
2399
2400 export interface ExecFileSyncOptions {
2401 cwd?: string;
2402 input?: string | Buffer;
2403 stdio?: any;
2404 env?: any;
2405 uid?: number;
2406 gid?: number;
2407 timeout?: number;
2408 killSignal?: string;
2409 maxBuffer?: number;
2410 encoding?: string;
2411 windowsHide?: boolean;
2412 }
2413 export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
2414 encoding: BufferEncoding;
2415 }
2416 export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
2417 encoding: string; // specify `null`.
2418 }
2419 export function execFileSync(command: string): Buffer;
2420 export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
2421 export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
2422 export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
2423 export function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
2424 export function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
2425 export function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
2426}
2427
2428declare module "url" {
2429 import { ParsedUrlQuery } from 'querystring';
2430
2431 export interface UrlObjectCommon {
2432 auth?: string;
2433 hash?: string;
2434 host?: string;
2435 hostname?: string;
2436 href?: string;
2437 path?: string;
2438 pathname?: string;
2439 protocol?: string;
2440 search?: string;
2441 slashes?: boolean;
2442 }
2443
2444 // Input to `url.format`
2445 export interface UrlObject extends UrlObjectCommon {
2446 port?: string | number;
2447 query?: string | null | { [key: string]: any };
2448 }
2449
2450 // Output of `url.parse`
2451 export interface Url extends UrlObjectCommon {
2452 port?: string;
2453 query?: string | null | ParsedUrlQuery;
2454 }
2455
2456 export interface UrlWithParsedQuery extends Url {
2457 query: ParsedUrlQuery;
2458 }
2459
2460 export interface UrlWithStringQuery extends Url {
2461 query: string | null;
2462 }
2463
2464 export function parse(urlStr: string): UrlWithStringQuery;
2465 export function parse(urlStr: string, parseQueryString: false | undefined, slashesDenoteHost?: boolean): UrlWithStringQuery;
2466 export function parse(urlStr: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
2467 export function parse(urlStr: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
2468
2469 export function format(URL: URL, options?: URLFormatOptions): string;
2470 export function format(urlObject: UrlObject | string): string;
2471 export function resolve(from: string, to: string): string;
2472
2473 export function domainToASCII(domain: string): string;
2474 export function domainToUnicode(domain: string): string;
2475
2476 export interface URLFormatOptions {
2477 auth?: boolean;
2478 fragment?: boolean;
2479 search?: boolean;
2480 unicode?: boolean;
2481 }
2482
2483 export class URL {
2484 constructor(input: string, base?: string | URL);
2485 hash: string;
2486 host: string;
2487 hostname: string;
2488 href: string;
2489 readonly origin: string;
2490 password: string;
2491 pathname: string;
2492 port: string;
2493 protocol: string;
2494 search: string;
2495 readonly searchParams: URLSearchParams;
2496 username: string;
2497 toString(): string;
2498 toJSON(): string;
2499 }
2500
2501 export class URLSearchParams implements Iterable<[string, string]> {
2502 constructor(init?: URLSearchParams | string | { [key: string]: string | string[] | undefined } | Iterable<[string, string]> | Array<[string, string]>);
2503 append(name: string, value: string): void;
2504 delete(name: string): void;
2505 entries(): IterableIterator<[string, string]>;
2506 forEach(callback: (value: string, name: string) => void): void;
2507 get(name: string): string | null;
2508 getAll(name: string): string[];
2509 has(name: string): boolean;
2510 keys(): IterableIterator<string>;
2511 set(name: string, value: string): void;
2512 sort(): void;
2513 toString(): string;
2514 values(): IterableIterator<string>;
2515 [Symbol.iterator](): IterableIterator<[string, string]>;
2516 }
2517}
2518
2519declare module "dns" {
2520 // Supported getaddrinfo flags.
2521 export const ADDRCONFIG: number;
2522 export const V4MAPPED: number;
2523
2524 export interface LookupOptions {
2525 family?: number;
2526 hints?: number;
2527 all?: boolean;
2528 }
2529
2530 export interface LookupOneOptions extends LookupOptions {
2531 all?: false;
2532 }
2533
2534 export interface LookupAllOptions extends LookupOptions {
2535 all: true;
2536 }
2537
2538 export interface LookupAddress {
2539 address: string;
2540 family: number;
2541 }
2542
2543 export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
2544 export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
2545 export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void;
2546 export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void;
2547 export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void;
2548
2549 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2550 export namespace lookup {
2551 export function __promisify__(hostname: string, options: LookupAllOptions): Promise<{ address: LookupAddress[] }>;
2552 export function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<{ address: string, family: number }>;
2553 export function __promisify__(hostname: string, options?: LookupOptions | number): Promise<{ address: string | LookupAddress[], family?: number }>;
2554 }
2555
2556 export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException, hostname: string, service: string) => void): void;
2557
2558 export namespace lookupService {
2559 export function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
2560 }
2561
2562 export interface ResolveOptions {
2563 ttl: boolean;
2564 }
2565
2566 export interface ResolveWithTtlOptions extends ResolveOptions {
2567 ttl: true;
2568 }
2569
2570 export interface RecordWithTtl {
2571 address: string;
2572 ttl: number;
2573 }
2574
2575 export interface AnyRecordWithTtl extends RecordWithTtl {
2576 type: "A" | "AAAA";
2577 }
2578
2579 export interface MxRecord {
2580 priority: number;
2581 exchange: string;
2582 }
2583
2584 export interface AnyMxRecord extends MxRecord {
2585 type: "MX";
2586 }
2587
2588 export interface NaptrRecord {
2589 flags: string;
2590 service: string;
2591 regexp: string;
2592 replacement: string;
2593 order: number;
2594 preference: number;
2595 }
2596
2597 export interface AnyNaptrRecord extends NaptrRecord {
2598 type: "NAPTR";
2599 }
2600
2601 export interface SoaRecord {
2602 nsname: string;
2603 hostmaster: string;
2604 serial: number;
2605 refresh: number;
2606 retry: number;
2607 expire: number;
2608 minttl: number;
2609 }
2610
2611 export interface AnySoaRecord extends SoaRecord {
2612 type: "SOA";
2613 }
2614
2615 export interface SrvRecord {
2616 priority: number;
2617 weight: number;
2618 port: number;
2619 name: string;
2620 }
2621
2622 export interface AnySrvRecord extends SrvRecord {
2623 type: "SRV";
2624 }
2625
2626 export interface AnyTxtRecord {
2627 type: "TXT";
2628 entries: string[];
2629 }
2630
2631 export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2632 export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2633 export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2634 export function resolve(hostname: string, rrtype: "ANY", callback: (err: NodeJS.ErrnoException, addresses: ReadonlyArray<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>) => void): void;
2635 export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2636 export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void;
2637 export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void;
2638 export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2639 export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2640 export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void;
2641 export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void;
2642 export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void;
2643 export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void;
2644
2645 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2646 export namespace resolve {
2647 export function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
2648 export function __promisify__(hostname: string, rrtype: "ANY"): Promise<ReadonlyArray<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>>;
2649 export function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
2650 export function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
2651 export function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
2652 export function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
2653 export function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
2654 export function __promisify__(hostname: string, rrtype?: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]>;
2655 }
2656
2657 export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2658 export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void;
2659 export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void;
2660
2661 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2662 export namespace resolve4 {
2663 export function __promisify__(hostname: string): Promise<string[]>;
2664 export function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2665 export function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
2666 }
2667
2668 export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2669 export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void;
2670 export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void;
2671
2672 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
2673 export namespace resolve6 {
2674 export function __promisify__(hostname: string): Promise<string[]>;
2675 export function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
2676 export function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
2677 }
2678
2679 export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: ReadonlyArray<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>) => void): void;
2680 export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2681 export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void;
2682 export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void;
2683 export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2684 export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void;
2685 export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void;
2686 export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void;
2687 export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void;
2688
2689 export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void;
2690 export function setServers(servers: string[]): void;
2691
2692 // Error codes
2693 export var NODATA: string;
2694 export var FORMERR: string;
2695 export var SERVFAIL: string;
2696 export var NOTFOUND: string;
2697 export var NOTIMP: string;
2698 export var REFUSED: string;
2699 export var BADQUERY: string;
2700 export var BADNAME: string;
2701 export var BADFAMILY: string;
2702 export var BADRESP: string;
2703 export var CONNREFUSED: string;
2704 export var TIMEOUT: string;
2705 export var EOF: string;
2706 export var FILE: string;
2707 export var NOMEM: string;
2708 export var DESTRUCTION: string;
2709 export var BADSTR: string;
2710 export var BADFLAGS: string;
2711 export var NONAME: string;
2712 export var BADHINTS: string;
2713 export var NOTINITIALIZED: string;
2714 export var LOADIPHLPAPI: string;
2715 export var ADDRGETNETWORKPARAMS: string;
2716 export var CANCELLED: string;
2717}
2718
2719declare module "net" {
2720 import * as stream from "stream";
2721 import * as events from "events";
2722 import * as dns from "dns";
2723
2724 type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
2725
2726 export interface AddressInfo {
2727 address: string;
2728 family: string;
2729 port: number;
2730 }
2731
2732 export interface SocketConstructorOpts {
2733 fd?: number;
2734 allowHalfOpen?: boolean;
2735 readable?: boolean;
2736 writable?: boolean;
2737 }
2738
2739 export interface TcpSocketConnectOpts {
2740 port: number;
2741 host?: string;
2742 localAddress?: string;
2743 localPort?: number;
2744 hints?: number;
2745 family?: number;
2746 lookup?: LookupFunction;
2747 }
2748
2749 export interface IpcSocketConnectOpts {
2750 path: string;
2751 }
2752
2753 export type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
2754
2755 export class Socket extends stream.Duplex {
2756 constructor(options?: SocketConstructorOpts);
2757
2758 // Extended base methods
2759 write(buffer: Buffer): boolean;
2760 write(buffer: Buffer, cb?: Function): boolean;
2761 write(str: string, cb?: Function): boolean;
2762 write(str: string, encoding?: string, cb?: Function): boolean;
2763 write(str: string, encoding?: string, fd?: string): boolean;
2764 write(data: any, encoding?: string, callback?: Function): void;
2765
2766 connect(options: SocketConnectOpts, connectionListener?: Function): this;
2767 connect(port: number, host: string, connectionListener?: Function): this;
2768 connect(port: number, connectionListener?: Function): this;
2769 connect(path: string, connectionListener?: Function): this;
2770
2771 bufferSize: number;
2772 setEncoding(encoding?: string): this;
2773 destroy(err?: any): void;
2774 pause(): this;
2775 resume(): this;
2776 setTimeout(timeout: number, callback?: Function): this;
2777 setNoDelay(noDelay?: boolean): this;
2778 setKeepAlive(enable?: boolean, initialDelay?: number): this;
2779 address(): AddressInfo | string;
2780 unref(): void;
2781 ref(): void;
2782
2783 remoteAddress?: string;
2784 remoteFamily?: string;
2785 remotePort?: number;
2786 localAddress: string;
2787 localPort: number;
2788 bytesRead: number;
2789 bytesWritten: number;
2790 connecting: boolean;
2791 destroyed: boolean;
2792
2793 // Extended base methods
2794 end(): void;
2795 end(buffer: Buffer, cb?: Function): void;
2796 end(str: string, cb?: Function): void;
2797 end(str: string, encoding?: string, cb?: Function): void;
2798 end(data?: any, encoding?: string): void;
2799
2800 /**
2801 * events.EventEmitter
2802 * 1. close
2803 * 2. connect
2804 * 3. data
2805 * 4. drain
2806 * 5. end
2807 * 6. error
2808 * 7. lookup
2809 * 8. timeout
2810 */
2811 addListener(event: string, listener: (...args: any[]) => void): this;
2812 addListener(event: "close", listener: (had_error: boolean) => void): this;
2813 addListener(event: "connect", listener: () => void): this;
2814 addListener(event: "data", listener: (data: Buffer) => void): this;
2815 addListener(event: "drain", listener: () => void): this;
2816 addListener(event: "end", listener: () => void): this;
2817 addListener(event: "error", listener: (err: Error) => void): this;
2818 addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
2819 addListener(event: "timeout", listener: () => void): this;
2820
2821 emit(event: string | symbol, ...args: any[]): boolean;
2822 emit(event: "close", had_error: boolean): boolean;
2823 emit(event: "connect"): boolean;
2824 emit(event: "data", data: Buffer): boolean;
2825 emit(event: "drain"): boolean;
2826 emit(event: "end"): boolean;
2827 emit(event: "error", err: Error): boolean;
2828 emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
2829 emit(event: "timeout"): boolean;
2830
2831 on(event: string, listener: (...args: any[]) => void): this;
2832 on(event: "close", listener: (had_error: boolean) => void): this;
2833 on(event: "connect", listener: () => void): this;
2834 on(event: "data", listener: (data: Buffer) => void): this;
2835 on(event: "drain", listener: () => void): this;
2836 on(event: "end", listener: () => void): this;
2837 on(event: "error", listener: (err: Error) => void): this;
2838 on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
2839 on(event: "timeout", listener: () => void): this;
2840
2841 once(event: string, listener: (...args: any[]) => void): this;
2842 once(event: "close", listener: (had_error: boolean) => void): this;
2843 once(event: "connect", listener: () => void): this;
2844 once(event: "data", listener: (data: Buffer) => void): this;
2845 once(event: "drain", listener: () => void): this;
2846 once(event: "end", listener: () => void): this;
2847 once(event: "error", listener: (err: Error) => void): this;
2848 once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
2849 once(event: "timeout", listener: () => void): this;
2850
2851 prependListener(event: string, listener: (...args: any[]) => void): this;
2852 prependListener(event: "close", listener: (had_error: boolean) => void): this;
2853 prependListener(event: "connect", listener: () => void): this;
2854 prependListener(event: "data", listener: (data: Buffer) => void): this;
2855 prependListener(event: "drain", listener: () => void): this;
2856 prependListener(event: "end", listener: () => void): this;
2857 prependListener(event: "error", listener: (err: Error) => void): this;
2858 prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
2859 prependListener(event: "timeout", listener: () => void): this;
2860
2861 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2862 prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
2863 prependOnceListener(event: "connect", listener: () => void): this;
2864 prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
2865 prependOnceListener(event: "drain", listener: () => void): this;
2866 prependOnceListener(event: "end", listener: () => void): this;
2867 prependOnceListener(event: "error", listener: (err: Error) => void): this;
2868 prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
2869 prependOnceListener(event: "timeout", listener: () => void): this;
2870 }
2871
2872 export interface ListenOptions {
2873 port?: number;
2874 host?: string;
2875 backlog?: number;
2876 path?: string;
2877 exclusive?: boolean;
2878 readableAll?: boolean;
2879 writableAll?: boolean;
2880 }
2881
2882 // https://github.com/nodejs/node/blob/master/lib/net.js
2883 export class Server extends events.EventEmitter {
2884 constructor(connectionListener?: (socket: Socket) => void);
2885 constructor(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void);
2886
2887 listen(port?: number, hostname?: string, backlog?: number, listeningListener?: Function): this;
2888 listen(port?: number, hostname?: string, listeningListener?: Function): this;
2889 listen(port?: number, backlog?: number, listeningListener?: Function): this;
2890 listen(port?: number, listeningListener?: Function): this;
2891 listen(path: string, backlog?: number, listeningListener?: Function): this;
2892 listen(path: string, listeningListener?: Function): this;
2893 listen(options: ListenOptions, listeningListener?: Function): this;
2894 listen(handle: any, backlog?: number, listeningListener?: Function): this;
2895 listen(handle: any, listeningListener?: Function): this;
2896 close(callback?: Function): this;
2897 address(): AddressInfo | string;
2898 getConnections(cb: (error: Error | null, count: number) => void): void;
2899 ref(): this;
2900 unref(): this;
2901 maxConnections: number;
2902 connections: number;
2903 listening: boolean;
2904
2905 /**
2906 * events.EventEmitter
2907 * 1. close
2908 * 2. connection
2909 * 3. error
2910 * 4. listening
2911 */
2912 addListener(event: string, listener: (...args: any[]) => void): this;
2913 addListener(event: "close", listener: () => void): this;
2914 addListener(event: "connection", listener: (socket: Socket) => void): this;
2915 addListener(event: "error", listener: (err: Error) => void): this;
2916 addListener(event: "listening", listener: () => void): this;
2917
2918 emit(event: string | symbol, ...args: any[]): boolean;
2919 emit(event: "close"): boolean;
2920 emit(event: "connection", socket: Socket): boolean;
2921 emit(event: "error", err: Error): boolean;
2922 emit(event: "listening"): boolean;
2923
2924 on(event: string, listener: (...args: any[]) => void): this;
2925 on(event: "close", listener: () => void): this;
2926 on(event: "connection", listener: (socket: Socket) => void): this;
2927 on(event: "error", listener: (err: Error) => void): this;
2928 on(event: "listening", listener: () => void): this;
2929
2930 once(event: string, listener: (...args: any[]) => void): this;
2931 once(event: "close", listener: () => void): this;
2932 once(event: "connection", listener: (socket: Socket) => void): this;
2933 once(event: "error", listener: (err: Error) => void): this;
2934 once(event: "listening", listener: () => void): this;
2935
2936 prependListener(event: string, listener: (...args: any[]) => void): this;
2937 prependListener(event: "close", listener: () => void): this;
2938 prependListener(event: "connection", listener: (socket: Socket) => void): this;
2939 prependListener(event: "error", listener: (err: Error) => void): this;
2940 prependListener(event: "listening", listener: () => void): this;
2941
2942 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2943 prependOnceListener(event: "close", listener: () => void): this;
2944 prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
2945 prependOnceListener(event: "error", listener: (err: Error) => void): this;
2946 prependOnceListener(event: "listening", listener: () => void): this;
2947 }
2948
2949 export interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
2950 timeout?: number;
2951 }
2952
2953 export interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
2954 timeout?: number;
2955 }
2956
2957 export type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
2958
2959 export function createServer(connectionListener?: (socket: Socket) => void): Server;
2960 export function createServer(options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean }, connectionListener?: (socket: Socket) => void): Server;
2961 export function connect(options: NetConnectOpts, connectionListener?: Function): Socket;
2962 export function connect(port: number, host?: string, connectionListener?: Function): Socket;
2963 export function connect(path: string, connectionListener?: Function): Socket;
2964 export function createConnection(options: NetConnectOpts, connectionListener?: Function): Socket;
2965 export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
2966 export function createConnection(path: string, connectionListener?: Function): Socket;
2967 export function isIP(input: string): number;
2968 export function isIPv4(input: string): boolean;
2969 export function isIPv6(input: string): boolean;
2970}
2971
2972declare module "dgram" {
2973 import { AddressInfo } from "net";
2974 import * as dns from "dns";
2975 import * as events from "events";
2976
2977 export interface RemoteInfo {
2978 address: string;
2979 family: string;
2980 port: number;
2981 }
2982
2983 export interface BindOptions {
2984 port: number;
2985 address?: string;
2986 exclusive?: boolean;
2987 }
2988
2989 type SocketType = "udp4" | "udp6";
2990
2991 export interface SocketOptions {
2992 type: SocketType;
2993 reuseAddr?: boolean;
2994 recvBufferSize?: number;
2995 sendBufferSize?: number;
2996 lookup?: (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void) => void;
2997 }
2998
2999 export function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
3000 export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
3001
3002 export class Socket extends events.EventEmitter {
3003 send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
3004 send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
3005 bind(port?: number, address?: string, callback?: () => void): void;
3006 bind(port?: number, callback?: () => void): void;
3007 bind(callback?: () => void): void;
3008 bind(options: BindOptions, callback?: Function): void;
3009 close(callback?: () => void): void;
3010 address(): AddressInfo | string;
3011 setBroadcast(flag: boolean): void;
3012 setTTL(ttl: number): void;
3013 setMulticastTTL(ttl: number): void;
3014 setMulticastInterface(multicastInterface: string): void;
3015 setMulticastLoopback(flag: boolean): void;
3016 addMembership(multicastAddress: string, multicastInterface?: string): void;
3017 dropMembership(multicastAddress: string, multicastInterface?: string): void;
3018 ref(): this;
3019 unref(): this;
3020 setRecvBufferSize(size: number): void;
3021 setSendBufferSize(size: number): void;
3022 getRecvBufferSize(): number;
3023 getSendBufferSize(): number;
3024
3025 /**
3026 * events.EventEmitter
3027 * 1. close
3028 * 2. error
3029 * 3. listening
3030 * 4. message
3031 */
3032 addListener(event: string, listener: (...args: any[]) => void): this;
3033 addListener(event: "close", listener: () => void): this;
3034 addListener(event: "error", listener: (err: Error) => void): this;
3035 addListener(event: "listening", listener: () => void): this;
3036 addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
3037
3038 emit(event: string | symbol, ...args: any[]): boolean;
3039 emit(event: "close"): boolean;
3040 emit(event: "error", err: Error): boolean;
3041 emit(event: "listening"): boolean;
3042 emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean;
3043
3044 on(event: string, listener: (...args: any[]) => void): this;
3045 on(event: "close", listener: () => void): this;
3046 on(event: "error", listener: (err: Error) => void): this;
3047 on(event: "listening", listener: () => void): this;
3048 on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
3049
3050 once(event: string, listener: (...args: any[]) => void): this;
3051 once(event: "close", listener: () => void): this;
3052 once(event: "error", listener: (err: Error) => void): this;
3053 once(event: "listening", listener: () => void): this;
3054 once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
3055
3056 prependListener(event: string, listener: (...args: any[]) => void): this;
3057 prependListener(event: "close", listener: () => void): this;
3058 prependListener(event: "error", listener: (err: Error) => void): this;
3059 prependListener(event: "listening", listener: () => void): this;
3060 prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
3061
3062 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
3063 prependOnceListener(event: "close", listener: () => void): this;
3064 prependOnceListener(event: "error", listener: (err: Error) => void): this;
3065 prependOnceListener(event: "listening", listener: () => void): this;
3066 prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this;
3067 }
3068}
3069
3070declare module "fs" {
3071 import * as stream from "stream";
3072 import * as events from "events";
3073 import { URL } from "url";
3074
3075 /**
3076 * Valid types for path values in "fs".
3077 */
3078 export type PathLike = string | Buffer | URL;
3079
3080 export class Stats {
3081 isFile(): boolean;
3082 isDirectory(): boolean;
3083 isBlockDevice(): boolean;
3084 isCharacterDevice(): boolean;
3085 isSymbolicLink(): boolean;
3086 isFIFO(): boolean;
3087 isSocket(): boolean;
3088 dev: number;
3089 ino: number;
3090 mode: number;
3091 nlink: number;
3092 uid: number;
3093 gid: number;
3094 rdev: number;
3095 size: number;
3096 blksize: number;
3097 blocks: number;
3098 atimeMs: number;
3099 mtimeMs: number;
3100 ctimeMs: number;
3101 birthtimeMs: number;
3102 atime: Date;
3103 mtime: Date;
3104 ctime: Date;
3105 birthtime: Date;
3106 }
3107
3108 export interface FSWatcher extends events.EventEmitter {
3109 close(): void;
3110
3111 /**
3112 * events.EventEmitter
3113 * 1. change
3114 * 2. error
3115 */
3116 addListener(event: string, listener: (...args: any[]) => void): this;
3117 addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
3118 addListener(event: "error", listener: (error: Error) => void): this;
3119
3120 on(event: string, listener: (...args: any[]) => void): this;
3121 on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
3122 on(event: "error", listener: (error: Error) => void): this;
3123
3124 once(event: string, listener: (...args: any[]) => void): this;
3125 once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
3126 once(event: "error", listener: (error: Error) => void): this;
3127
3128 prependListener(event: string, listener: (...args: any[]) => void): this;
3129 prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
3130 prependListener(event: "error", listener: (error: Error) => void): this;
3131
3132 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
3133 prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
3134 prependOnceListener(event: "error", listener: (error: Error) => void): this;
3135 }
3136
3137 export class ReadStream extends stream.Readable {
3138 close(): void;
3139 destroy(): void;
3140 bytesRead: number;
3141 path: string | Buffer;
3142
3143 /**
3144 * events.EventEmitter
3145 * 1. open
3146 * 2. close
3147 */
3148 addListener(event: string, listener: (...args: any[]) => void): this;
3149 addListener(event: "open", listener: (fd: number) => void): this;
3150 addListener(event: "close", listener: () => void): this;
3151
3152 on(event: string, listener: (...args: any[]) => void): this;
3153 on(event: "open", listener: (fd: number) => void): this;
3154 on(event: "close", listener: () => void): this;
3155
3156 once(event: string, listener: (...args: any[]) => void): this;
3157 once(event: "open", listener: (fd: number) => void): this;
3158 once(event: "close", listener: () => void): this;
3159
3160 prependListener(event: string, listener: (...args: any[]) => void): this;
3161 prependListener(event: "open", listener: (fd: number) => void): this;
3162 prependListener(event: "close", listener: () => void): this;
3163
3164 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
3165 prependOnceListener(event: "open", listener: (fd: number) => void): this;
3166 prependOnceListener(event: "close", listener: () => void): this;
3167 }
3168
3169 export class WriteStream extends stream.Writable {
3170 close(): void;
3171 bytesWritten: number;
3172 path: string | Buffer;
3173
3174 /**
3175 * events.EventEmitter
3176 * 1. open
3177 * 2. close
3178 */
3179 addListener(event: string, listener: (...args: any[]) => void): this;
3180 addListener(event: "open", listener: (fd: number) => void): this;
3181 addListener(event: "close", listener: () => void): this;
3182
3183 on(event: string, listener: (...args: any[]) => void): this;
3184 on(event: "open", listener: (fd: number) => void): this;
3185 on(event: "close", listener: () => void): this;
3186
3187 once(event: string, listener: (...args: any[]) => void): this;
3188 once(event: "open", listener: (fd: number) => void): this;
3189 once(event: "close", listener: () => void): this;
3190
3191 prependListener(event: string, listener: (...args: any[]) => void): this;
3192 prependListener(event: "open", listener: (fd: number) => void): this;
3193 prependListener(event: "close", listener: () => void): this;
3194
3195 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
3196 prependOnceListener(event: "open", listener: (fd: number) => void): this;
3197 prependOnceListener(event: "close", listener: () => void): this;
3198 }
3199
3200 /**
3201 * Asynchronous rename(2) - Change the name or location of a file or directory.
3202 * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3203 * URL support is _experimental_.
3204 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3205 * URL support is _experimental_.
3206 */
3207 export function rename(oldPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3208
3209 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3210 export namespace rename {
3211 /**
3212 * Asynchronous rename(2) - Change the name or location of a file or directory.
3213 * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3214 * URL support is _experimental_.
3215 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3216 * URL support is _experimental_.
3217 */
3218 export function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;
3219 }
3220
3221 /**
3222 * Synchronous rename(2) - Change the name or location of a file or directory.
3223 * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3224 * URL support is _experimental_.
3225 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3226 * URL support is _experimental_.
3227 */
3228 export function renameSync(oldPath: PathLike, newPath: PathLike): void;
3229
3230 /**
3231 * Asynchronous truncate(2) - Truncate a file to a specified length.
3232 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3233 * @param len If not specified, defaults to `0`.
3234 */
3235 export function truncate(path: PathLike, len: number | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
3236
3237 /**
3238 * Asynchronous truncate(2) - Truncate a file to a specified length.
3239 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3240 * URL support is _experimental_.
3241 */
3242 export function truncate(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3243
3244 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3245 export namespace truncate {
3246 /**
3247 * Asynchronous truncate(2) - Truncate a file to a specified length.
3248 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3249 * @param len If not specified, defaults to `0`.
3250 */
3251 export function __promisify__(path: PathLike, len?: number | null): Promise<void>;
3252 }
3253
3254 /**
3255 * Synchronous truncate(2) - Truncate a file to a specified length.
3256 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3257 * @param len If not specified, defaults to `0`.
3258 */
3259 export function truncateSync(path: PathLike, len?: number | null): void;
3260
3261 /**
3262 * Asynchronous ftruncate(2) - Truncate a file to a specified length.
3263 * @param fd A file descriptor.
3264 * @param len If not specified, defaults to `0`.
3265 */
3266 export function ftruncate(fd: number, len: number | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
3267
3268 /**
3269 * Asynchronous ftruncate(2) - Truncate a file to a specified length.
3270 * @param fd A file descriptor.
3271 */
3272 export function ftruncate(fd: number, callback: (err: NodeJS.ErrnoException) => void): void;
3273
3274 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3275 export namespace ftruncate {
3276 /**
3277 * Asynchronous ftruncate(2) - Truncate a file to a specified length.
3278 * @param fd A file descriptor.
3279 * @param len If not specified, defaults to `0`.
3280 */
3281 export function __promisify__(fd: number, len?: number | null): Promise<void>;
3282 }
3283
3284 /**
3285 * Synchronous ftruncate(2) - Truncate a file to a specified length.
3286 * @param fd A file descriptor.
3287 * @param len If not specified, defaults to `0`.
3288 */
3289 export function ftruncateSync(fd: number, len?: number | null): void;
3290
3291 /**
3292 * Asynchronous chown(2) - Change ownership of a file.
3293 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3294 */
3295 export function chown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
3296
3297 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3298 export namespace chown {
3299 /**
3300 * Asynchronous chown(2) - Change ownership of a file.
3301 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3302 */
3303 export function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
3304 }
3305
3306 /**
3307 * Synchronous chown(2) - Change ownership of a file.
3308 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3309 */
3310 export function chownSync(path: PathLike, uid: number, gid: number): void;
3311
3312 /**
3313 * Asynchronous fchown(2) - Change ownership of a file.
3314 * @param fd A file descriptor.
3315 */
3316 export function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
3317
3318 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3319 export namespace fchown {
3320 /**
3321 * Asynchronous fchown(2) - Change ownership of a file.
3322 * @param fd A file descriptor.
3323 */
3324 export function __promisify__(fd: number, uid: number, gid: number): Promise<void>;
3325 }
3326
3327 /**
3328 * Synchronous fchown(2) - Change ownership of a file.
3329 * @param fd A file descriptor.
3330 */
3331 export function fchownSync(fd: number, uid: number, gid: number): void;
3332
3333 /**
3334 * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
3335 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3336 */
3337 export function lchown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException) => void): void;
3338
3339 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3340 export namespace lchown {
3341 /**
3342 * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
3343 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3344 */
3345 export function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
3346 }
3347
3348 /**
3349 * Synchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
3350 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3351 */
3352 export function lchownSync(path: PathLike, uid: number, gid: number): void;
3353
3354 /**
3355 * Asynchronous chmod(2) - Change permissions of a file.
3356 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3357 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3358 */
3359 export function chmod(path: PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void;
3360
3361 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3362 export namespace chmod {
3363 /**
3364 * Asynchronous chmod(2) - Change permissions of a file.
3365 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3366 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3367 */
3368 export function __promisify__(path: PathLike, mode: string | number): Promise<void>;
3369 }
3370
3371 /**
3372 * Synchronous chmod(2) - Change permissions of a file.
3373 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3374 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3375 */
3376 export function chmodSync(path: PathLike, mode: string | number): void;
3377
3378 /**
3379 * Asynchronous fchmod(2) - Change permissions of a file.
3380 * @param fd A file descriptor.
3381 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3382 */
3383 export function fchmod(fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void;
3384
3385 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3386 export namespace fchmod {
3387 /**
3388 * Asynchronous fchmod(2) - Change permissions of a file.
3389 * @param fd A file descriptor.
3390 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3391 */
3392 export function __promisify__(fd: number, mode: string | number): Promise<void>;
3393 }
3394
3395 /**
3396 * Synchronous fchmod(2) - Change permissions of a file.
3397 * @param fd A file descriptor.
3398 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3399 */
3400 export function fchmodSync(fd: number, mode: string | number): void;
3401
3402 /**
3403 * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
3404 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3405 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3406 */
3407 export function lchmod(path: PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException) => void): void;
3408
3409 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3410 export namespace lchmod {
3411 /**
3412 * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
3413 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3414 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3415 */
3416 export function __promisify__(path: PathLike, mode: string | number): Promise<void>;
3417 }
3418
3419 /**
3420 * Synchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
3421 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3422 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
3423 */
3424 export function lchmodSync(path: PathLike, mode: string | number): void;
3425
3426 /**
3427 * Asynchronous stat(2) - Get file status.
3428 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3429 */
3430 export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException, stats: Stats) => void): void;
3431
3432 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3433 export namespace stat {
3434 /**
3435 * Asynchronous stat(2) - Get file status.
3436 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3437 */
3438 export function __promisify__(path: PathLike): Promise<Stats>;
3439 }
3440
3441 /**
3442 * Synchronous stat(2) - Get file status.
3443 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3444 */
3445 export function statSync(path: PathLike): Stats;
3446
3447 /**
3448 * Asynchronous fstat(2) - Get file status.
3449 * @param fd A file descriptor.
3450 */
3451 export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => void): void;
3452
3453 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3454 export namespace fstat {
3455 /**
3456 * Asynchronous fstat(2) - Get file status.
3457 * @param fd A file descriptor.
3458 */
3459 export function __promisify__(fd: number): Promise<Stats>;
3460 }
3461
3462 /**
3463 * Synchronous fstat(2) - Get file status.
3464 * @param fd A file descriptor.
3465 */
3466 export function fstatSync(fd: number): Stats;
3467
3468 /**
3469 * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
3470 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3471 */
3472 export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException, stats: Stats) => void): void;
3473
3474 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3475 export namespace lstat {
3476 /**
3477 * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
3478 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3479 */
3480 export function __promisify__(path: PathLike): Promise<Stats>;
3481 }
3482
3483 /**
3484 * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
3485 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3486 */
3487 export function lstatSync(path: PathLike): Stats;
3488
3489 /**
3490 * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
3491 * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3492 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3493 */
3494 export function link(existingPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3495
3496 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3497 export namespace link {
3498 /**
3499 * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
3500 * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3501 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3502 */
3503 export function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
3504 }
3505
3506 /**
3507 * Synchronous link(2) - Create a new link (also known as a hard link) to an existing file.
3508 * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3509 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
3510 */
3511 export function linkSync(existingPath: PathLike, newPath: PathLike): void;
3512
3513 /**
3514 * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
3515 * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
3516 * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
3517 * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
3518 * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
3519 */
3520 export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
3521
3522 /**
3523 * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
3524 * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
3525 * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
3526 */
3527 export function symlink(target: PathLike, path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3528
3529 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3530 export namespace symlink {
3531 /**
3532 * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
3533 * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
3534 * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
3535 * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
3536 * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
3537 */
3538 export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
3539
3540 export type Type = "dir" | "file" | "junction";
3541 }
3542
3543 /**
3544 * Synchronous symlink(2) - Create a new symbolic link to an existing file.
3545 * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
3546 * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
3547 * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
3548 * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
3549 */
3550 export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
3551
3552 /**
3553 * Asynchronous readlink(2) - read value of a symbolic link.
3554 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3555 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3556 */
3557 export function readlink(path: PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, linkString: string) => void): void;
3558
3559 /**
3560 * Asynchronous readlink(2) - read value of a symbolic link.
3561 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3562 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3563 */
3564 export function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException, linkString: Buffer) => void): void;
3565
3566 /**
3567 * Asynchronous readlink(2) - read value of a symbolic link.
3568 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3569 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3570 */
3571 export function readlink(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, linkString: string | Buffer) => void): void;
3572
3573 /**
3574 * Asynchronous readlink(2) - read value of a symbolic link.
3575 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3576 */
3577 export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException, linkString: string) => void): void;
3578
3579 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3580 export namespace readlink {
3581 /**
3582 * Asynchronous readlink(2) - read value of a symbolic link.
3583 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3584 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3585 */
3586 export function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
3587
3588 /**
3589 * Asynchronous readlink(2) - read value of a symbolic link.
3590 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3591 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3592 */
3593 export function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
3594
3595 /**
3596 * Asynchronous readlink(2) - read value of a symbolic link.
3597 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3598 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3599 */
3600 export function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
3601 }
3602
3603 /**
3604 * Synchronous readlink(2) - read value of a symbolic link.
3605 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3606 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3607 */
3608 export function readlinkSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
3609
3610 /**
3611 * Synchronous readlink(2) - read value of a symbolic link.
3612 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3613 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3614 */
3615 export function readlinkSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
3616
3617 /**
3618 * Synchronous readlink(2) - read value of a symbolic link.
3619 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3620 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3621 */
3622 export function readlinkSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
3623
3624 /**
3625 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3626 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3627 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3628 */
3629 export function realpath(path: PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
3630
3631 /**
3632 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3633 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3634 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3635 */
3636 export function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException, resolvedPath: Buffer) => void): void;
3637
3638 /**
3639 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3640 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3641 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3642 */
3643 export function realpath(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string | Buffer) => void): void;
3644
3645 /**
3646 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3647 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3648 */
3649 export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
3650
3651 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3652 export namespace realpath {
3653 /**
3654 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3655 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3656 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3657 */
3658 export function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
3659
3660 /**
3661 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3662 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3663 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3664 */
3665 export function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
3666
3667 /**
3668 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
3669 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3670 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3671 */
3672 export function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
3673
3674 export function native(path: PathLike, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
3675 export function native(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException, resolvedPath: Buffer) => void): void;
3676 export function native(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, resolvedPath: string | Buffer) => void): void;
3677 export function native(path: PathLike, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => void): void;
3678 }
3679
3680 /**
3681 * Synchronous realpath(3) - return the canonicalized absolute pathname.
3682 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3683 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3684 */
3685 export function realpathSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
3686
3687 /**
3688 * Synchronous realpath(3) - return the canonicalized absolute pathname.
3689 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3690 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3691 */
3692 export function realpathSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
3693
3694 /**
3695 * Synchronous realpath(3) - return the canonicalized absolute pathname.
3696 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3697 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3698 */
3699 export function realpathSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
3700
3701 export namespace realpathSync {
3702 export function native(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
3703 export function native(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
3704 export function native(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
3705 }
3706
3707 /**
3708 * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
3709 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3710 */
3711 export function unlink(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3712
3713 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3714 export namespace unlink {
3715 /**
3716 * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
3717 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3718 */
3719 export function __promisify__(path: PathLike): Promise<void>;
3720 }
3721
3722 /**
3723 * Synchronous unlink(2) - delete a name and possibly the file it refers to.
3724 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3725 */
3726 export function unlinkSync(path: PathLike): void;
3727
3728 /**
3729 * Asynchronous rmdir(2) - delete a directory.
3730 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3731 */
3732 export function rmdir(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3733
3734 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3735 export namespace rmdir {
3736 /**
3737 * Asynchronous rmdir(2) - delete a directory.
3738 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3739 */
3740 export function __promisify__(path: PathLike): Promise<void>;
3741 }
3742
3743 /**
3744 * Synchronous rmdir(2) - delete a directory.
3745 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3746 */
3747 export function rmdirSync(path: PathLike): void;
3748
3749 /**
3750 * Asynchronous mkdir(2) - create a directory.
3751 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3752 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
3753 */
3754 export function mkdir(path: PathLike, mode: number | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
3755
3756 /**
3757 * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
3758 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3759 */
3760 export function mkdir(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
3761
3762 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3763 export namespace mkdir {
3764 /**
3765 * Asynchronous mkdir(2) - create a directory.
3766 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3767 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
3768 */
3769 export function __promisify__(path: PathLike, mode?: number | string | null): Promise<void>;
3770 }
3771
3772 /**
3773 * Synchronous mkdir(2) - create a directory.
3774 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3775 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
3776 */
3777 export function mkdirSync(path: PathLike, mode?: number | string | null): void;
3778
3779 /**
3780 * Asynchronously creates a unique temporary directory.
3781 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3782 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3783 */
3784 export function mkdtemp(prefix: string, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, folder: string) => void): void;
3785
3786 /**
3787 * Asynchronously creates a unique temporary directory.
3788 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3789 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3790 */
3791 export function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException, folder: Buffer) => void): void;
3792
3793 /**
3794 * Asynchronously creates a unique temporary directory.
3795 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3796 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3797 */
3798 export function mkdtemp(prefix: string, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, folder: string | Buffer) => void): void;
3799
3800 /**
3801 * Asynchronously creates a unique temporary directory.
3802 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3803 */
3804 export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException, folder: string) => void): void;
3805
3806 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3807 export namespace mkdtemp {
3808 /**
3809 * Asynchronously creates a unique temporary directory.
3810 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3811 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3812 */
3813 export function __promisify__(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
3814
3815 /**
3816 * Asynchronously creates a unique temporary directory.
3817 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3818 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3819 */
3820 export function __promisify__(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
3821
3822 /**
3823 * Asynchronously creates a unique temporary directory.
3824 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3825 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3826 */
3827 export function __promisify__(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
3828 }
3829
3830 /**
3831 * Synchronously creates a unique temporary directory.
3832 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3833 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3834 */
3835 export function mkdtempSync(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
3836
3837 /**
3838 * Synchronously creates a unique temporary directory.
3839 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3840 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3841 */
3842 export function mkdtempSync(prefix: string, options: { encoding: "buffer" } | "buffer"): Buffer;
3843
3844 /**
3845 * Synchronously creates a unique temporary directory.
3846 * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
3847 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3848 */
3849 export function mkdtempSync(prefix: string, options?: { encoding?: string | null } | string | null): string | Buffer;
3850
3851 /**
3852 * Asynchronous readdir(3) - read a directory.
3853 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3854 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3855 */
3856 export function readdir(path: PathLike, options: { encoding: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
3857
3858 /**
3859 * Asynchronous readdir(3) - read a directory.
3860 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3861 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3862 */
3863 export function readdir(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException, files: Buffer[]) => void): void;
3864
3865 /**
3866 * Asynchronous readdir(3) - read a directory.
3867 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3868 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3869 */
3870 export function readdir(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException, files: string[] | Buffer[]) => void): void;
3871
3872 /**
3873 * Asynchronous readdir(3) - read a directory.
3874 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3875 */
3876 export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
3877
3878 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3879 export namespace readdir {
3880 /**
3881 * Asynchronous readdir(3) - read a directory.
3882 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3883 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3884 */
3885 export function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null } | BufferEncoding | null): Promise<string[]>;
3886
3887 /**
3888 * Asynchronous readdir(3) - read a directory.
3889 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3890 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3891 */
3892 export function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer" }): Promise<Buffer[]>;
3893
3894 /**
3895 * Asynchronous readdir(3) - read a directory.
3896 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3897 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3898 */
3899 export function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string[] | Buffer[]>;
3900 }
3901
3902 /**
3903 * Synchronous readdir(3) - read a directory.
3904 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3905 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3906 */
3907 export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null } | BufferEncoding | null): string[];
3908
3909 /**
3910 * Synchronous readdir(3) - read a directory.
3911 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3912 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3913 */
3914 export function readdirSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer[];
3915
3916 /**
3917 * Synchronous readdir(3) - read a directory.
3918 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3919 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
3920 */
3921 export function readdirSync(path: PathLike, options?: { encoding?: string | null } | string | null): string[] | Buffer[];
3922
3923 /**
3924 * Asynchronous close(2) - close a file descriptor.
3925 * @param fd A file descriptor.
3926 */
3927 export function close(fd: number, callback: (err: NodeJS.ErrnoException) => void): void;
3928
3929 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3930 export namespace close {
3931 /**
3932 * Asynchronous close(2) - close a file descriptor.
3933 * @param fd A file descriptor.
3934 */
3935 export function __promisify__(fd: number): Promise<void>;
3936 }
3937
3938 /**
3939 * Synchronous close(2) - close a file descriptor.
3940 * @param fd A file descriptor.
3941 */
3942 export function closeSync(fd: number): void;
3943
3944 /**
3945 * Asynchronous open(2) - open and possibly create a file.
3946 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3947 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
3948 */
3949 export function open(path: PathLike, flags: string | number, mode: string | number | undefined | null, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
3950
3951 /**
3952 * Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
3953 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3954 */
3955 export function open(path: PathLike, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
3956
3957 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3958 export namespace open {
3959 /**
3960 * Asynchronous open(2) - open and possibly create a file.
3961 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3962 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
3963 */
3964 export function __promisify__(path: PathLike, flags: string | number, mode?: string | number | null): Promise<number>;
3965 }
3966
3967 /**
3968 * Synchronous open(2) - open and possibly create a file, returning a file descriptor..
3969 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3970 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
3971 */
3972 export function openSync(path: PathLike, flags: string | number, mode?: string | number | null): number;
3973
3974 /**
3975 * Asynchronously change file timestamps of the file referenced by the supplied path.
3976 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3977 * @param atime The last access time. If a string is provided, it will be coerced to number.
3978 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
3979 */
3980 export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void;
3981
3982 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
3983 export namespace utimes {
3984 /**
3985 * Asynchronously change file timestamps of the file referenced by the supplied path.
3986 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3987 * @param atime The last access time. If a string is provided, it will be coerced to number.
3988 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
3989 */
3990 export function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
3991 }
3992
3993 /**
3994 * Synchronously change file timestamps of the file referenced by the supplied path.
3995 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
3996 * @param atime The last access time. If a string is provided, it will be coerced to number.
3997 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
3998 */
3999 export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
4000
4001 /**
4002 * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
4003 * @param fd A file descriptor.
4004 * @param atime The last access time. If a string is provided, it will be coerced to number.
4005 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
4006 */
4007 export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException) => void): void;
4008
4009 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4010 export namespace futimes {
4011 /**
4012 * Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
4013 * @param fd A file descriptor.
4014 * @param atime The last access time. If a string is provided, it will be coerced to number.
4015 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
4016 */
4017 export function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
4018 }
4019
4020 /**
4021 * Synchronously change file timestamps of the file referenced by the supplied file descriptor.
4022 * @param fd A file descriptor.
4023 * @param atime The last access time. If a string is provided, it will be coerced to number.
4024 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
4025 */
4026 export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
4027
4028 /**
4029 * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
4030 * @param fd A file descriptor.
4031 */
4032 export function fsync(fd: number, callback: (err: NodeJS.ErrnoException) => void): void;
4033
4034 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4035 export namespace fsync {
4036 /**
4037 * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
4038 * @param fd A file descriptor.
4039 */
4040 export function __promisify__(fd: number): Promise<void>;
4041 }
4042
4043 /**
4044 * Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
4045 * @param fd A file descriptor.
4046 */
4047 export function fsyncSync(fd: number): void;
4048
4049 /**
4050 * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
4051 * @param fd A file descriptor.
4052 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4053 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4054 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4055 */
4056 export function write<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number | undefined | null, length: number | undefined | null, position: number | undefined | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void;
4057
4058 /**
4059 * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
4060 * @param fd A file descriptor.
4061 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4062 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4063 */
4064 export function write<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number | undefined | null, length: number | undefined | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void;
4065
4066 /**
4067 * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
4068 * @param fd A file descriptor.
4069 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4070 */
4071 export function write<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number | undefined | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void;
4072
4073 /**
4074 * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
4075 * @param fd A file descriptor.
4076 */
4077 export function write<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException, written: number, buffer: TBuffer) => void): void;
4078
4079 /**
4080 * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
4081 * @param fd A file descriptor.
4082 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4083 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4084 * @param encoding The expected string encoding.
4085 */
4086 export function write(fd: number, string: any, position: number | undefined | null, encoding: string | undefined | null, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
4087
4088 /**
4089 * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
4090 * @param fd A file descriptor.
4091 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4092 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4093 */
4094 export function write(fd: number, string: any, position: number | undefined | null, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
4095
4096 /**
4097 * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
4098 * @param fd A file descriptor.
4099 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4100 */
4101 export function write(fd: number, string: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
4102
4103 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4104 export namespace write {
4105 /**
4106 * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
4107 * @param fd A file descriptor.
4108 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4109 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4110 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4111 */
4112 export function __promisify__<TBuffer extends Buffer | Uint8Array>(fd: number, buffer?: TBuffer, offset?: number, length?: number, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
4113
4114 /**
4115 * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
4116 * @param fd A file descriptor.
4117 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4118 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4119 * @param encoding The expected string encoding.
4120 */
4121 export function __promisify__(fd: number, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
4122 }
4123
4124 /**
4125 * Synchronously writes `buffer` to the file referenced by the supplied file descriptor, returning the number of bytes written.
4126 * @param fd A file descriptor.
4127 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4128 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4129 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4130 */
4131 export function writeSync(fd: number, buffer: Buffer | Uint8Array, offset?: number | null, length?: number | null, position?: number | null): number;
4132
4133 /**
4134 * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
4135 * @param fd A file descriptor.
4136 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4137 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4138 * @param encoding The expected string encoding.
4139 */
4140 export function writeSync(fd: number, string: any, position?: number | null, encoding?: string | null): number;
4141
4142 /**
4143 * Asynchronously reads data from the file referenced by the supplied file descriptor.
4144 * @param fd A file descriptor.
4145 * @param buffer The buffer that the data will be written to.
4146 * @param offset The offset in the buffer at which to start writing.
4147 * @param length The number of bytes to read.
4148 * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
4149 */
4150 export function read<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number, length: number, position: number | null, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: TBuffer) => void): void;
4151
4152 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4153 export namespace read {
4154 /**
4155 * @param fd A file descriptor.
4156 * @param buffer The buffer that the data will be written to.
4157 * @param offset The offset in the buffer at which to start writing.
4158 * @param length The number of bytes to read.
4159 * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
4160 */
4161 export function __promisify__<TBuffer extends Buffer | Uint8Array>(fd: number, buffer: TBuffer, offset: number, length: number, position: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
4162 }
4163
4164 /**
4165 * Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
4166 * @param fd A file descriptor.
4167 * @param buffer The buffer that the data will be written to.
4168 * @param offset The offset in the buffer at which to start writing.
4169 * @param length The number of bytes to read.
4170 * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
4171 */
4172 export function readSync(fd: number, buffer: Buffer | Uint8Array, offset: number, length: number, position: number | null): number;
4173
4174 /**
4175 * Asynchronously reads the entire contents of a file.
4176 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4177 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4178 * @param options An object that may contain an optional flag.
4179 * If a flag is not provided, it defaults to `'r'`.
4180 */
4181 export function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
4182
4183 /**
4184 * Asynchronously reads the entire contents of a file.
4185 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4186 * URL support is _experimental_.
4187 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4188 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4189 * If a flag is not provided, it defaults to `'r'`.
4190 */
4191 export function readFile(path: PathLike | number, options: { encoding: string; flag?: string; } | string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
4192
4193 /**
4194 * Asynchronously reads the entire contents of a file.
4195 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4196 * URL support is _experimental_.
4197 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4198 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4199 * If a flag is not provided, it defaults to `'r'`.
4200 */
4201 export function readFile(path: PathLike | number, options: { encoding?: string | null; flag?: string; } | string | undefined | null, callback: (err: NodeJS.ErrnoException, data: string | Buffer) => void): void;
4202
4203 /**
4204 * Asynchronously reads the entire contents of a file.
4205 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4206 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4207 */
4208 export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
4209
4210 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4211 export namespace readFile {
4212 /**
4213 * Asynchronously reads the entire contents of a file.
4214 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4215 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4216 * @param options An object that may contain an optional flag.
4217 * If a flag is not provided, it defaults to `'r'`.
4218 */
4219 export function __promisify__(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Promise<Buffer>;
4220
4221 /**
4222 * Asynchronously reads the entire contents of a file.
4223 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4224 * URL support is _experimental_.
4225 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4226 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4227 * If a flag is not provided, it defaults to `'r'`.
4228 */
4229 export function __promisify__(path: PathLike | number, options: { encoding: string; flag?: string; } | string): Promise<string>;
4230
4231 /**
4232 * Asynchronously reads the entire contents of a file.
4233 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4234 * URL support is _experimental_.
4235 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4236 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4237 * If a flag is not provided, it defaults to `'r'`.
4238 */
4239 export function __promisify__(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): Promise<string | Buffer>;
4240 }
4241
4242 /**
4243 * Synchronously reads the entire contents of a file.
4244 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4245 * URL support is _experimental_.
4246 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4247 * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
4248 */
4249 export function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
4250
4251 /**
4252 * Synchronously reads the entire contents of a file.
4253 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4254 * URL support is _experimental_.
4255 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4256 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4257 * If a flag is not provided, it defaults to `'r'`.
4258 */
4259 export function readFileSync(path: PathLike | number, options: { encoding: string; flag?: string; } | string): string;
4260
4261 /**
4262 * Synchronously reads the entire contents of a file.
4263 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4264 * URL support is _experimental_.
4265 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4266 * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
4267 * If a flag is not provided, it defaults to `'r'`.
4268 */
4269 export function readFileSync(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): string | Buffer;
4270
4271 /**
4272 * Asynchronously writes data to a file, replacing the file if it already exists.
4273 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4274 * URL support is _experimental_.
4275 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4276 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4277 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4278 * If `encoding` is not supplied, the default of `'utf8'` is used.
4279 * If `mode` is not supplied, the default of `0o666` is used.
4280 * If `mode` is a string, it is parsed as an octal integer.
4281 * If `flag` is not supplied, the default of `'w'` is used.
4282 */
4283 export function writeFile(path: PathLike | number, data: any, options: { encoding?: string | null; mode?: number | string; flag?: string; } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
4284
4285 /**
4286 * Asynchronously writes data to a file, replacing the file if it already exists.
4287 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4288 * URL support is _experimental_.
4289 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4290 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4291 */
4292 export function writeFile(path: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
4293
4294 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4295 export namespace writeFile {
4296 /**
4297 * Asynchronously writes data to a file, replacing the file if it already exists.
4298 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4299 * URL support is _experimental_.
4300 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4301 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4302 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4303 * If `encoding` is not supplied, the default of `'utf8'` is used.
4304 * If `mode` is not supplied, the default of `0o666` is used.
4305 * If `mode` is a string, it is parsed as an octal integer.
4306 * If `flag` is not supplied, the default of `'w'` is used.
4307 */
4308 export function __promisify__(path: PathLike | number, data: any, options?: { encoding?: string | null; mode?: number | string; flag?: string; } | string | null): Promise<void>;
4309 }
4310
4311 /**
4312 * Synchronously writes data to a file, replacing the file if it already exists.
4313 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4314 * URL support is _experimental_.
4315 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4316 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4317 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4318 * If `encoding` is not supplied, the default of `'utf8'` is used.
4319 * If `mode` is not supplied, the default of `0o666` is used.
4320 * If `mode` is a string, it is parsed as an octal integer.
4321 * If `flag` is not supplied, the default of `'w'` is used.
4322 */
4323 export function writeFileSync(path: PathLike | number, data: any, options?: { encoding?: string | null; mode?: number | string; flag?: string; } | string | null): void;
4324
4325 /**
4326 * Asynchronously append data to a file, creating the file if it does not exist.
4327 * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
4328 * URL support is _experimental_.
4329 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4330 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4331 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4332 * If `encoding` is not supplied, the default of `'utf8'` is used.
4333 * If `mode` is not supplied, the default of `0o666` is used.
4334 * If `mode` is a string, it is parsed as an octal integer.
4335 * If `flag` is not supplied, the default of `'a'` is used.
4336 */
4337 export function appendFile(file: PathLike | number, data: any, options: { encoding?: string | null, mode?: string | number, flag?: string } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
4338
4339 /**
4340 * Asynchronously append data to a file, creating the file if it does not exist.
4341 * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
4342 * URL support is _experimental_.
4343 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4344 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4345 */
4346 export function appendFile(file: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
4347
4348 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4349 export namespace appendFile {
4350 /**
4351 * Asynchronously append data to a file, creating the file if it does not exist.
4352 * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
4353 * URL support is _experimental_.
4354 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4355 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4356 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4357 * If `encoding` is not supplied, the default of `'utf8'` is used.
4358 * If `mode` is not supplied, the default of `0o666` is used.
4359 * If `mode` is a string, it is parsed as an octal integer.
4360 * If `flag` is not supplied, the default of `'a'` is used.
4361 */
4362 export function __promisify__(file: PathLike | number, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string } | string | null): Promise<void>;
4363 }
4364
4365 /**
4366 * Synchronously append data to a file, creating the file if it does not exist.
4367 * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
4368 * URL support is _experimental_.
4369 * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
4370 * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
4371 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4372 * If `encoding` is not supplied, the default of `'utf8'` is used.
4373 * If `mode` is not supplied, the default of `0o666` is used.
4374 * If `mode` is a string, it is parsed as an octal integer.
4375 * If `flag` is not supplied, the default of `'a'` is used.
4376 */
4377 export function appendFileSync(file: PathLike | number, data: any, options?: { encoding?: string | null; mode?: number | string; flag?: string; } | string | null): void;
4378
4379 /**
4380 * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
4381 */
4382 export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
4383
4384 /**
4385 * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
4386 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4387 * URL support is _experimental_.
4388 */
4389 export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
4390
4391 /**
4392 * Stop watching for changes on `filename`.
4393 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4394 * URL support is _experimental_.
4395 */
4396 export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
4397
4398 /**
4399 * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
4400 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4401 * URL support is _experimental_.
4402 * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
4403 * If `encoding` is not supplied, the default of `'utf8'` is used.
4404 * If `persistent` is not supplied, the default of `true` is used.
4405 * If `recursive` is not supplied, the default of `false` is used.
4406 */
4407 export function watch(filename: PathLike, options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null, listener?: (event: string, filename: string) => void): FSWatcher;
4408
4409 /**
4410 * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
4411 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4412 * URL support is _experimental_.
4413 * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
4414 * If `encoding` is not supplied, the default of `'utf8'` is used.
4415 * If `persistent` is not supplied, the default of `true` is used.
4416 * If `recursive` is not supplied, the default of `false` is used.
4417 */
4418 export function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
4419
4420 /**
4421 * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
4422 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4423 * URL support is _experimental_.
4424 * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
4425 * If `encoding` is not supplied, the default of `'utf8'` is used.
4426 * If `persistent` is not supplied, the default of `true` is used.
4427 * If `recursive` is not supplied, the default of `false` is used.
4428 */
4429 export function watch(filename: PathLike, options: { encoding?: string | null, persistent?: boolean, recursive?: boolean } | string | null, listener?: (event: string, filename: string | Buffer) => void): FSWatcher;
4430
4431 /**
4432 * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
4433 * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4434 * URL support is _experimental_.
4435 */
4436 export function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
4437
4438 /**
4439 * Asynchronously tests whether or not the given path exists by checking with the file system.
4440 * @deprecated
4441 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4442 * URL support is _experimental_.
4443 */
4444 export function exists(path: PathLike, callback: (exists: boolean) => void): void;
4445
4446 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4447 export namespace exists {
4448 /**
4449 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4450 * URL support is _experimental_.
4451 */
4452 function __promisify__(path: PathLike): Promise<boolean>;
4453 }
4454
4455 /**
4456 * Synchronously tests whether or not the given path exists by checking with the file system.
4457 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4458 * URL support is _experimental_.
4459 */
4460 export function existsSync(path: PathLike): boolean;
4461
4462 export namespace constants {
4463 // File Access Constants
4464
4465 /** Constant for fs.access(). File is visible to the calling process. */
4466 export const F_OK: number;
4467
4468 /** Constant for fs.access(). File can be read by the calling process. */
4469 export const R_OK: number;
4470
4471 /** Constant for fs.access(). File can be written by the calling process. */
4472 export const W_OK: number;
4473
4474 /** Constant for fs.access(). File can be executed by the calling process. */
4475 export const X_OK: number;
4476
4477 // File Copy Constants
4478
4479 /** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
4480 export const COPYFILE_EXCL: number;
4481
4482 /** Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used. */
4483 export const COPYFILE_FICLONE: number;
4484
4485 /** Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink. If the underlying platform does not support copy-on-write, then the operation will fail with an error. */
4486 export const COPYFILE_FICLONE_FORCE: number;
4487
4488 // File Open Constants
4489
4490 /** Constant for fs.open(). Flag indicating to open a file for read-only access. */
4491 export const O_RDONLY: number;
4492
4493 /** Constant for fs.open(). Flag indicating to open a file for write-only access. */
4494 export const O_WRONLY: number;
4495
4496 /** Constant for fs.open(). Flag indicating to open a file for read-write access. */
4497 export const O_RDWR: number;
4498
4499 /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
4500 export const O_CREAT: number;
4501
4502 /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
4503 export const O_EXCL: number;
4504
4505 /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */
4506 export const O_NOCTTY: number;
4507
4508 /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
4509 export const O_TRUNC: number;
4510
4511 /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
4512 export const O_APPEND: number;
4513
4514 /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
4515 export const O_DIRECTORY: number;
4516
4517 /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */
4518 export const O_NOATIME: number;
4519
4520 /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
4521 export const O_NOFOLLOW: number;
4522
4523 /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
4524 export const O_SYNC: number;
4525
4526 /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
4527 export const O_DSYNC: number;
4528
4529 /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
4530 export const O_SYMLINK: number;
4531
4532 /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
4533 export const O_DIRECT: number;
4534
4535 /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
4536 export const O_NONBLOCK: number;
4537
4538 // File Type Constants
4539
4540 /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
4541 export const S_IFMT: number;
4542
4543 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
4544 export const S_IFREG: number;
4545
4546 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
4547 export const S_IFDIR: number;
4548
4549 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
4550 export const S_IFCHR: number;
4551
4552 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
4553 export const S_IFBLK: number;
4554
4555 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
4556 export const S_IFIFO: number;
4557
4558 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
4559 export const S_IFLNK: number;
4560
4561 /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
4562 export const S_IFSOCK: number;
4563
4564 // File Mode Constants
4565
4566 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
4567 export const S_IRWXU: number;
4568
4569 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
4570 export const S_IRUSR: number;
4571
4572 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
4573 export const S_IWUSR: number;
4574
4575 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
4576 export const S_IXUSR: number;
4577
4578 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
4579 export const S_IRWXG: number;
4580
4581 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
4582 export const S_IRGRP: number;
4583
4584 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
4585 export const S_IWGRP: number;
4586
4587 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
4588 export const S_IXGRP: number;
4589
4590 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
4591 export const S_IRWXO: number;
4592
4593 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
4594 export const S_IROTH: number;
4595
4596 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
4597 export const S_IWOTH: number;
4598
4599 /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
4600 export const S_IXOTH: number;
4601 }
4602
4603 /**
4604 * Asynchronously tests a user's permissions for the file specified by path.
4605 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4606 * URL support is _experimental_.
4607 */
4608 export function access(path: PathLike, mode: number | undefined, callback: (err: NodeJS.ErrnoException) => void): void;
4609
4610 /**
4611 * Asynchronously tests a user's permissions for the file specified by path.
4612 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4613 * URL support is _experimental_.
4614 */
4615 export function access(path: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
4616
4617 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4618 export namespace access {
4619 /**
4620 * Asynchronously tests a user's permissions for the file specified by path.
4621 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4622 * URL support is _experimental_.
4623 */
4624 export function __promisify__(path: PathLike, mode?: number): Promise<void>;
4625 }
4626
4627 /**
4628 * Synchronously tests a user's permissions for the file specified by path.
4629 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4630 * URL support is _experimental_.
4631 */
4632 export function accessSync(path: PathLike, mode?: number): void;
4633
4634 /**
4635 * Returns a new `ReadStream` object.
4636 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4637 * URL support is _experimental_.
4638 */
4639 export function createReadStream(path: PathLike, options?: string | {
4640 flags?: string;
4641 encoding?: string;
4642 fd?: number;
4643 mode?: number;
4644 autoClose?: boolean;
4645 start?: number;
4646 end?: number;
4647 highWaterMark?: number;
4648 }): ReadStream;
4649
4650 /**
4651 * Returns a new `WriteStream` object.
4652 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4653 * URL support is _experimental_.
4654 */
4655 export function createWriteStream(path: PathLike, options?: string | {
4656 flags?: string;
4657 encoding?: string;
4658 fd?: number;
4659 mode?: number;
4660 autoClose?: boolean;
4661 start?: number;
4662 }): WriteStream;
4663
4664 /**
4665 * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4666 * @param fd A file descriptor.
4667 */
4668 export function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException) => void): void;
4669
4670 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4671 export namespace fdatasync {
4672 /**
4673 * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4674 * @param fd A file descriptor.
4675 */
4676 export function __promisify__(fd: number): Promise<void>;
4677 }
4678
4679 /**
4680 * Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4681 * @param fd A file descriptor.
4682 */
4683 export function fdatasyncSync(fd: number): void;
4684
4685 /**
4686 * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
4687 * No arguments other than a possible exception are given to the callback function.
4688 * Node.js makes no guarantees about the atomicity of the copy operation.
4689 * If an error occurs after the destination file has been opened for writing, Node.js will attempt
4690 * to remove the destination.
4691 * @param src A path to the source file.
4692 * @param dest A path to the destination file.
4693 */
4694 export function copyFile(src: PathLike, dest: PathLike, callback: (err: NodeJS.ErrnoException) => void): void;
4695 /**
4696 * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
4697 * No arguments other than a possible exception are given to the callback function.
4698 * Node.js makes no guarantees about the atomicity of the copy operation.
4699 * If an error occurs after the destination file has been opened for writing, Node.js will attempt
4700 * to remove the destination.
4701 * @param src A path to the source file.
4702 * @param dest A path to the destination file.
4703 * @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
4704 */
4705 export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: (err: NodeJS.ErrnoException) => void): void;
4706
4707 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
4708 export namespace copyFile {
4709 /**
4710 * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
4711 * No arguments other than a possible exception are given to the callback function.
4712 * Node.js makes no guarantees about the atomicity of the copy operation.
4713 * If an error occurs after the destination file has been opened for writing, Node.js will attempt
4714 * to remove the destination.
4715 * @param src A path to the source file.
4716 * @param dest A path to the destination file.
4717 * @param flags An optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
4718 */
4719 export function __promisify__(src: PathLike, dst: PathLike, flags?: number): Promise<void>;
4720 }
4721
4722 /**
4723 * Synchronously copies src to dest. By default, dest is overwritten if it already exists.
4724 * Node.js makes no guarantees about the atomicity of the copy operation.
4725 * If an error occurs after the destination file has been opened for writing, Node.js will attempt
4726 * to remove the destination.
4727 * @param src A path to the source file.
4728 * @param dest A path to the destination file.
4729 * @param flags An optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
4730 */
4731 export function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
4732
4733 export namespace promises {
4734 interface FileHandle {
4735 /**
4736 * Gets the file descriptor for this file handle.
4737 */
4738 readonly fd: number;
4739
4740 /**
4741 * Asynchronously append data to a file, creating the file if it does not exist. The underlying file will _not_ be closed automatically.
4742 * The `FileHandle` must have been opened for appending.
4743 * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
4744 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4745 * If `encoding` is not supplied, the default of `'utf8'` is used.
4746 * If `mode` is not supplied, the default of `0o666` is used.
4747 * If `mode` is a string, it is parsed as an octal integer.
4748 * If `flag` is not supplied, the default of `'a'` is used.
4749 */
4750 appendFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
4751
4752 /**
4753 * Asynchronous fchown(2) - Change ownership of a file.
4754 */
4755 chown(uid: number, gid: number): Promise<void>;
4756
4757 /**
4758 * Asynchronous fchmod(2) - Change permissions of a file.
4759 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
4760 */
4761 chmod(mode: string | number): Promise<void>;
4762
4763 /**
4764 * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4765 */
4766 datasync(): Promise<void>;
4767
4768 /**
4769 * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
4770 */
4771 sync(): Promise<void>;
4772
4773 /**
4774 * Asynchronously reads data from the file.
4775 * The `FileHandle` must have been opened for reading.
4776 * @param buffer The buffer that the data will be written to.
4777 * @param offset The offset in the buffer at which to start writing.
4778 * @param length The number of bytes to read.
4779 * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
4780 */
4781 read<TBuffer extends Buffer | Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
4782
4783 /**
4784 * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
4785 * The `FileHandle` must have been opened for reading.
4786 * @param options An object that may contain an optional flag.
4787 * If a flag is not provided, it defaults to `'r'`.
4788 */
4789 readFile(options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
4790
4791 /**
4792 * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
4793 * The `FileHandle` must have been opened for reading.
4794 * @param options An object that may contain an optional flag.
4795 * If a flag is not provided, it defaults to `'r'`.
4796 */
4797 readFile(options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
4798
4799 /**
4800 * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
4801 * The `FileHandle` must have been opened for reading.
4802 * @param options An object that may contain an optional flag.
4803 * If a flag is not provided, it defaults to `'r'`.
4804 */
4805 readFile(options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
4806
4807 /**
4808 * Asynchronous fstat(2) - Get file status.
4809 */
4810 stat(): Promise<Stats>;
4811
4812 /**
4813 * Asynchronous ftruncate(2) - Truncate a file to a specified length.
4814 * @param len If not specified, defaults to `0`.
4815 */
4816 truncate(len?: number): Promise<void>;
4817
4818 /**
4819 * Asynchronously change file timestamps of the file.
4820 * @param atime The last access time. If a string is provided, it will be coerced to number.
4821 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
4822 */
4823 utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
4824
4825 /**
4826 * Asynchronously writes `buffer` to the file.
4827 * The `FileHandle` must have been opened for writing.
4828 * @param buffer The buffer that the data will be written to.
4829 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4830 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4831 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4832 */
4833 write<TBuffer extends Buffer | Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
4834
4835 /**
4836 * Asynchronously writes `string` to the file.
4837 * The `FileHandle` must have been opened for writing.
4838 * It is unsafe to call `write()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
4839 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4840 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4841 * @param encoding The expected string encoding.
4842 */
4843 write(data: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
4844
4845 /**
4846 * Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will _not_ be closed automatically.
4847 * The `FileHandle` must have been opened for writing.
4848 * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
4849 * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
4850 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
4851 * If `encoding` is not supplied, the default of `'utf8'` is used.
4852 * If `mode` is not supplied, the default of `0o666` is used.
4853 * If `mode` is a string, it is parsed as an octal integer.
4854 * If `flag` is not supplied, the default of `'w'` is used.
4855 */
4856 writeFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
4857
4858 /**
4859 * Asynchronous close(2) - close a `FileHandle`.
4860 */
4861 close(): Promise<void>;
4862 }
4863
4864 /**
4865 * Asynchronously tests a user's permissions for the file specified by path.
4866 * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
4867 * URL support is _experimental_.
4868 */
4869 function access(path: PathLike, mode?: number): Promise<void>;
4870
4871 /**
4872 * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists.
4873 * Node.js makes no guarantees about the atomicity of the copy operation.
4874 * If an error occurs after the destination file has been opened for writing, Node.js will attempt
4875 * to remove the destination.
4876 * @param src A path to the source file.
4877 * @param dest A path to the destination file.
4878 * @param flags An optional integer that specifies the behavior of the copy operation. The only
4879 * supported flag is `fs.constants.COPYFILE_EXCL`, which causes the copy operation to fail if
4880 * `dest` already exists.
4881 */
4882 function copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>;
4883
4884 /**
4885 * Asynchronous open(2) - open and possibly create a file.
4886 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4887 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not
4888 * supplied, defaults to `0o666`.
4889 */
4890 function open(path: PathLike, flags: string | number, mode?: string | number): Promise<FileHandle>;
4891
4892 /**
4893 * Asynchronously reads data from the file referenced by the supplied `FileHandle`.
4894 * @param handle A `FileHandle`.
4895 * @param buffer The buffer that the data will be written to.
4896 * @param offset The offset in the buffer at which to start writing.
4897 * @param length The number of bytes to read.
4898 * @param position The offset from the beginning of the file from which data should be read. If
4899 * `null`, data will be read from the current position.
4900 */
4901 function read<TBuffer extends Buffer | Uint8Array>(handle: FileHandle, buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
4902
4903 /**
4904 * Asynchronously writes `buffer` to the file referenced by the supplied `FileHandle`.
4905 * It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
4906 * @param handle A `FileHandle`.
4907 * @param buffer The buffer that the data will be written to.
4908 * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
4909 * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
4910 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4911 */
4912 function write<TBuffer extends Buffer | Uint8Array>(handle: FileHandle, buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
4913
4914 /**
4915 * Asynchronously writes `string` to the file referenced by the supplied `FileHandle`.
4916 * It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
4917 * @param handle A `FileHandle`.
4918 * @param string A string to write. If something other than a string is supplied it will be coerced to a string.
4919 * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
4920 * @param encoding The expected string encoding.
4921 */
4922 function write(handle: FileHandle, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
4923
4924 /**
4925 * Asynchronous rename(2) - Change the name or location of a file or directory.
4926 * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
4927 * URL support is _experimental_.
4928 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
4929 * URL support is _experimental_.
4930 */
4931 function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
4932
4933 /**
4934 * Asynchronous truncate(2) - Truncate a file to a specified length.
4935 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4936 * @param len If not specified, defaults to `0`.
4937 */
4938 function truncate(path: PathLike, len?: number): Promise<void>;
4939
4940 /**
4941 * Asynchronous ftruncate(2) - Truncate a file to a specified length.
4942 * @param handle A `FileHandle`.
4943 * @param len If not specified, defaults to `0`.
4944 */
4945 function ftruncate(handle: FileHandle, len?: number): Promise<void>;
4946
4947 /**
4948 * Asynchronous rmdir(2) - delete a directory.
4949 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4950 */
4951 function rmdir(path: PathLike): Promise<void>;
4952
4953 /**
4954 * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
4955 * @param handle A `FileHandle`.
4956 */
4957 function fdatasync(handle: FileHandle): Promise<void>;
4958
4959 /**
4960 * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
4961 * @param handle A `FileHandle`.
4962 */
4963 function fsync(handle: FileHandle): Promise<void>;
4964
4965 /**
4966 * Asynchronous mkdir(2) - create a directory.
4967 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4968 * @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
4969 */
4970 function mkdir(path: PathLike, mode?: string | number): Promise<void>;
4971
4972 /**
4973 * Asynchronous readdir(3) - read a directory.
4974 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4975 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
4976 */
4977 function readdir(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string[]>;
4978
4979 /**
4980 * Asynchronous readdir(3) - read a directory.
4981 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4982 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
4983 */
4984 function readdir(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer[]>;
4985
4986 /**
4987 * Asynchronous readdir(3) - read a directory.
4988 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4989 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
4990 */
4991 function readdir(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string[] | Buffer[]>;
4992
4993 /**
4994 * Asynchronous readlink(2) - read value of a symbolic link.
4995 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
4996 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
4997 */
4998 function readlink(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
4999
5000 /**
5001 * Asynchronous readlink(2) - read value of a symbolic link.
5002 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5003 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5004 */
5005 function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
5006
5007 /**
5008 * Asynchronous readlink(2) - read value of a symbolic link.
5009 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5010 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5011 */
5012 function readlink(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
5013
5014 /**
5015 * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
5016 * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
5017 * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
5018 * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
5019 * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
5020 */
5021 function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
5022
5023 /**
5024 * Asynchronous fstat(2) - Get file status.
5025 * @param handle A `FileHandle`.
5026 */
5027 function fstat(handle: FileHandle): Promise<Stats>;
5028
5029 /**
5030 * Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
5031 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5032 */
5033 function lstat(path: PathLike): Promise<Stats>;
5034
5035 /**
5036 * Asynchronous stat(2) - Get file status.
5037 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5038 */
5039 function stat(path: PathLike): Promise<Stats>;
5040
5041 /**
5042 * Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
5043 * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
5044 * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
5045 */
5046 function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
5047
5048 /**
5049 * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
5050 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5051 */
5052 function unlink(path: PathLike): Promise<void>;
5053
5054 /**
5055 * Asynchronous fchmod(2) - Change permissions of a file.
5056 * @param handle A `FileHandle`.
5057 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
5058 */
5059 function fchmod(handle: FileHandle, mode: string | number): Promise<void>;
5060
5061 /**
5062 * Asynchronous chmod(2) - Change permissions of a file.
5063 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5064 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
5065 */
5066 function chmod(path: PathLike, mode: string | number): Promise<void>;
5067
5068 /**
5069 * Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
5070 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5071 * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
5072 */
5073 function lchmod(path: PathLike, mode: string | number): Promise<void>;
5074
5075 /**
5076 * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
5077 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5078 */
5079 function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
5080
5081 /**
5082 * Asynchronous fchown(2) - Change ownership of a file.
5083 * @param handle A `FileHandle`.
5084 */
5085 function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
5086
5087 /**
5088 * Asynchronous chown(2) - Change ownership of a file.
5089 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5090 */
5091 function chown(path: PathLike, uid: number, gid: number): Promise<void>;
5092
5093 /**
5094 * Asynchronously change file timestamps of the file referenced by the supplied path.
5095 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5096 * @param atime The last access time. If a string is provided, it will be coerced to number.
5097 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
5098 */
5099 function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
5100
5101 /**
5102 * Asynchronously change file timestamps of the file referenced by the supplied `FileHandle`.
5103 * @param handle A `FileHandle`.
5104 * @param atime The last access time. If a string is provided, it will be coerced to number.
5105 * @param mtime The last modified time. If a string is provided, it will be coerced to number.
5106 */
5107 function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
5108
5109 /**
5110 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
5111 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5112 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5113 */
5114 function realpath(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
5115
5116 /**
5117 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
5118 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5119 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5120 */
5121 function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
5122
5123 /**
5124 * Asynchronous realpath(3) - return the canonicalized absolute pathname.
5125 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5126 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5127 */
5128 function realpath(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
5129
5130 /**
5131 * Asynchronously creates a unique temporary directory.
5132 * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
5133 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5134 */
5135 function mkdtemp(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
5136
5137 /**
5138 * Asynchronously creates a unique temporary directory.
5139 * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
5140 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5141 */
5142 function mkdtemp(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
5143
5144 /**
5145 * Asynchronously creates a unique temporary directory.
5146 * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
5147 * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
5148 */
5149 function mkdtemp(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
5150
5151 /**
5152 * Asynchronously writes data to a file, replacing the file if it already exists.
5153 * It is unsafe to call `fsPromises.writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
5154 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5155 * URL support is _experimental_.
5156 * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
5157 * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
5158 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
5159 * If `encoding` is not supplied, the default of `'utf8'` is used.
5160 * If `mode` is not supplied, the default of `0o666` is used.
5161 * If `mode` is a string, it is parsed as an octal integer.
5162 * If `flag` is not supplied, the default of `'w'` is used.
5163 */
5164 function writeFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
5165
5166 /**
5167 * Asynchronously append data to a file, creating the file if it does not exist.
5168 * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
5169 * URL support is _experimental_.
5170 * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
5171 * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
5172 * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
5173 * If `encoding` is not supplied, the default of `'utf8'` is used.
5174 * If `mode` is not supplied, the default of `0o666` is used.
5175 * If `mode` is a string, it is parsed as an octal integer.
5176 * If `flag` is not supplied, the default of `'a'` is used.
5177 */
5178 function appendFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
5179
5180 /**
5181 * Asynchronously reads the entire contents of a file.
5182 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5183 * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
5184 * @param options An object that may contain an optional flag.
5185 * If a flag is not provided, it defaults to `'r'`.
5186 */
5187 function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
5188
5189 /**
5190 * Asynchronously reads the entire contents of a file.
5191 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5192 * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
5193 * @param options An object that may contain an optional flag.
5194 * If a flag is not provided, it defaults to `'r'`.
5195 */
5196 function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
5197
5198 /**
5199 * Asynchronously reads the entire contents of a file.
5200 * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
5201 * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
5202 * @param options An object that may contain an optional flag.
5203 * If a flag is not provided, it defaults to `'r'`.
5204 */
5205 function readFile(path: PathLike | FileHandle, options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
5206 }
5207}
5208
5209declare module "path" {
5210 /**
5211 * A parsed path object generated by path.parse() or consumed by path.format().
5212 */
5213 export interface ParsedPath {
5214 /**
5215 * The root of the path such as '/' or 'c:\'
5216 */
5217 root: string;
5218 /**
5219 * The full directory path such as '/home/user/dir' or 'c:\path\dir'
5220 */
5221 dir: string;
5222 /**
5223 * The file name including extension (if any) such as 'index.html'
5224 */
5225 base: string;
5226 /**
5227 * The file extension (if any) such as '.html'
5228 */
5229 ext: string;
5230 /**
5231 * The file name without extension (if any) such as 'index'
5232 */
5233 name: string;
5234 }
5235 export interface FormatInputPathObject {
5236 /**
5237 * The root of the path such as '/' or 'c:\'
5238 */
5239 root?: string;
5240 /**
5241 * The full directory path such as '/home/user/dir' or 'c:\path\dir'
5242 */
5243 dir?: string;
5244 /**
5245 * The file name including extension (if any) such as 'index.html'
5246 */
5247 base?: string;
5248 /**
5249 * The file extension (if any) such as '.html'
5250 */
5251 ext?: string;
5252 /**
5253 * The file name without extension (if any) such as 'index'
5254 */
5255 name?: string;
5256 }
5257
5258 /**
5259 * Normalize a string path, reducing '..' and '.' parts.
5260 * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
5261 *
5262 * @param p string path to normalize.
5263 */
5264 export function normalize(p: string): string;
5265 /**
5266 * Join all arguments together and normalize the resulting path.
5267 * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
5268 *
5269 * @param paths paths to join.
5270 */
5271 export function join(...paths: string[]): string;
5272 /**
5273 * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
5274 *
5275 * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
5276 *
5277 * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
5278 *
5279 * @param pathSegments string paths to join. Non-string arguments are ignored.
5280 */
5281 export function resolve(...pathSegments: string[]): string;
5282 /**
5283 * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
5284 *
5285 * @param path path to test.
5286 */
5287 export function isAbsolute(path: string): boolean;
5288 /**
5289 * Solve the relative path from {from} to {to}.
5290 * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
5291 */
5292 export function relative(from: string, to: string): string;
5293 /**
5294 * Return the directory name of a path. Similar to the Unix dirname command.
5295 *
5296 * @param p the path to evaluate.
5297 */
5298 export function dirname(p: string): string;
5299 /**
5300 * Return the last portion of a path. Similar to the Unix basename command.
5301 * Often used to extract the file name from a fully qualified path.
5302 *
5303 * @param p the path to evaluate.
5304 * @param ext optionally, an extension to remove from the result.
5305 */
5306 export function basename(p: string, ext?: string): string;
5307 /**
5308 * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
5309 * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
5310 *
5311 * @param p the path to evaluate.
5312 */
5313 export function extname(p: string): string;
5314 /**
5315 * The platform-specific file separator. '\\' or '/'.
5316 */
5317 export var sep: '\\' | '/';
5318 /**
5319 * The platform-specific file delimiter. ';' or ':'.
5320 */
5321 export var delimiter: ';' | ':';
5322 /**
5323 * Returns an object from a path string - the opposite of format().
5324 *
5325 * @param pathString path to evaluate.
5326 */
5327 export function parse(pathString: string): ParsedPath;
5328 /**
5329 * Returns a path string from an object - the opposite of parse().
5330 *
5331 * @param pathString path to evaluate.
5332 */
5333 export function format(pathObject: FormatInputPathObject): string;
5334
5335 export module posix {
5336 export function normalize(p: string): string;
5337 export function join(...paths: any[]): string;
5338 export function resolve(...pathSegments: any[]): string;
5339 export function isAbsolute(p: string): boolean;
5340 export function relative(from: string, to: string): string;
5341 export function dirname(p: string): string;
5342 export function basename(p: string, ext?: string): string;
5343 export function extname(p: string): string;
5344 export var sep: string;
5345 export var delimiter: string;
5346 export function parse(p: string): ParsedPath;
5347 export function format(pP: FormatInputPathObject): string;
5348 }
5349
5350 export module win32 {
5351 export function normalize(p: string): string;
5352 export function join(...paths: any[]): string;
5353 export function resolve(...pathSegments: any[]): string;
5354 export function isAbsolute(p: string): boolean;
5355 export function relative(from: string, to: string): string;
5356 export function dirname(p: string): string;
5357 export function basename(p: string, ext?: string): string;
5358 export function extname(p: string): string;
5359 export var sep: string;
5360 export var delimiter: string;
5361 export function parse(p: string): ParsedPath;
5362 export function format(pP: FormatInputPathObject): string;
5363 }
5364}
5365
5366declare module "string_decoder" {
5367 export interface NodeStringDecoder {
5368 write(buffer: Buffer): string;
5369 end(buffer?: Buffer): string;
5370 }
5371 export var StringDecoder: {
5372 new(encoding?: string): NodeStringDecoder;
5373 };
5374}
5375
5376declare module "tls" {
5377 import * as crypto from "crypto";
5378 import * as dns from "dns";
5379 import * as net from "net";
5380 import * as stream from "stream";
5381
5382 var CLIENT_RENEG_LIMIT: number;
5383 var CLIENT_RENEG_WINDOW: number;
5384
5385 export interface Certificate {
5386 /**
5387 * Country code.
5388 */
5389 C: string;
5390 /**
5391 * Street.
5392 */
5393 ST: string;
5394 /**
5395 * Locality.
5396 */
5397 L: string;
5398 /**
5399 * Organization.
5400 */
5401 O: string;
5402 /**
5403 * Organizational unit.
5404 */
5405 OU: string;
5406 /**
5407 * Common name.
5408 */
5409 CN: string;
5410 }
5411
5412 export interface PeerCertificate {
5413 subject: Certificate;
5414 issuer: Certificate;
5415 subjectaltname: string;
5416 infoAccess: { [index: string]: string[] | undefined };
5417 modulus: string;
5418 exponent: string;
5419 valid_from: string;
5420 valid_to: string;
5421 fingerprint: string;
5422 ext_key_usage: string[];
5423 serialNumber: string;
5424 raw: Buffer;
5425 }
5426
5427 export interface DetailedPeerCertificate extends PeerCertificate {
5428 issuerCertificate: DetailedPeerCertificate;
5429 }
5430
5431 export interface CipherNameAndProtocol {
5432 /**
5433 * The cipher name.
5434 */
5435 name: string;
5436 /**
5437 * SSL/TLS protocol version.
5438 */
5439 version: string;
5440 }
5441
5442 export class TLSSocket extends net.Socket {
5443 /**
5444 * Construct a new tls.TLSSocket object from an existing TCP socket.
5445 */
5446 constructor(socket: net.Socket, options?: {
5447 /**
5448 * An optional TLS context object from tls.createSecureContext()
5449 */
5450 secureContext?: SecureContext,
5451 /**
5452 * If true the TLS socket will be instantiated in server-mode.
5453 * Defaults to false.
5454 */
5455 isServer?: boolean,
5456 /**
5457 * An optional net.Server instance.
5458 */
5459 server?: net.Server,
5460 /**
5461 * If true the server will request a certificate from clients that
5462 * connect and attempt to verify that certificate. Defaults to
5463 * false.
5464 */
5465 requestCert?: boolean,
5466 /**
5467 * If true the server will reject any connection which is not
5468 * authorized with the list of supplied CAs. This option only has an
5469 * effect if requestCert is true. Defaults to false.
5470 */
5471 rejectUnauthorized?: boolean,
5472 /**
5473 * An array of strings or a Buffer naming possible NPN protocols.
5474 * (Protocols should be ordered by their priority.)
5475 */
5476 NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
5477 /**
5478 * An array of strings or a Buffer naming possible ALPN protocols.
5479 * (Protocols should be ordered by their priority.) When the server
5480 * receives both NPN and ALPN extensions from the client, ALPN takes
5481 * precedence over NPN and the server does not send an NPN extension
5482 * to the client.
5483 */
5484 ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array,
5485 /**
5486 * SNICallback(servername, cb) <Function> A function that will be
5487 * called if the client supports SNI TLS extension. Two arguments
5488 * will be passed when called: servername and cb. SNICallback should
5489 * invoke cb(null, ctx), where ctx is a SecureContext instance.
5490 * (tls.createSecureContext(...) can be used to get a proper
5491 * SecureContext.) If SNICallback wasn't provided the default callback
5492 * with high-level API will be used (see below).
5493 */
5494 SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void,
5495 /**
5496 * An optional Buffer instance containing a TLS session.
5497 */
5498 session?: Buffer,
5499 /**
5500 * If true, specifies that the OCSP status request extension will be
5501 * added to the client hello and an 'OCSPResponse' event will be
5502 * emitted on the socket before establishing a secure communication
5503 */
5504 requestOCSP?: boolean
5505 });
5506
5507 /**
5508 * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false.
5509 */
5510 authorized: boolean;
5511 /**
5512 * The reason why the peer's certificate has not been verified.
5513 * This property becomes available only when tlsSocket.authorized === false.
5514 */
5515 authorizationError: Error;
5516 /**
5517 * Static boolean value, always true.
5518 * May be used to distinguish TLS sockets from regular ones.
5519 */
5520 encrypted: boolean;
5521 /**
5522 * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection.
5523 * @returns Returns an object representing the cipher name
5524 * and the SSL/TLS protocol version of the current connection.
5525 */
5526 getCipher(): CipherNameAndProtocol;
5527 /**
5528 * Returns an object representing the peer's certificate.
5529 * The returned object has some properties corresponding to the field of the certificate.
5530 * If detailed argument is true the full chain with issuer property will be returned,
5531 * if false only the top certificate without issuer property.
5532 * If the peer does not provide a certificate, it returns null or an empty object.
5533 * @param detailed - If true; the full chain with issuer property will be returned.
5534 * @returns An object representing the peer's certificate.
5535 */
5536 getPeerCertificate(detailed: true): DetailedPeerCertificate;
5537 getPeerCertificate(detailed?: false): PeerCertificate;
5538 getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate;
5539 /**
5540 * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
5541 * The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process.
5542 * The value `null` will be returned for server sockets or disconnected client sockets.
5543 * See https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_version.html for more information.
5544 * @returns negotiated SSL/TLS protocol version of the current connection
5545 */
5546 getProtocol(): string | null;
5547 /**
5548 * Could be used to speed up handshake establishment when reconnecting to the server.
5549 * @returns ASN.1 encoded TLS session or undefined if none was negotiated.
5550 */
5551 getSession(): any;
5552 /**
5553 * NOTE: Works only with client TLS sockets.
5554 * Useful only for debugging, for session reuse provide session option to tls.connect().
5555 * @returns TLS session ticket or undefined if none was negotiated.
5556 */
5557 getTLSTicket(): any;
5558 /**
5559 * Initiate TLS renegotiation process.
5560 *
5561 * NOTE: Can be used to request peer's certificate after the secure connection has been established.
5562 * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout.
5563 * @param options - The options may contain the following fields: rejectUnauthorized,
5564 * requestCert (See tls.createServer() for details).
5565 * @param callback - callback(err) will be executed with null as err, once the renegotiation
5566 * is successfully completed.
5567 */
5568 renegotiate(options: { rejectUnauthorized?: boolean, requestCert?: boolean }, callback: (err: Error | null) => void): any;
5569 /**
5570 * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512).
5571 * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by
5572 * the TLS layer until the entire fragment is received and its integrity is verified;
5573 * large fragments can span multiple roundtrips, and their processing can be delayed due to packet
5574 * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead,
5575 * which may decrease overall server throughput.
5576 * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512).
5577 * @returns Returns true on success, false otherwise.
5578 */
5579 setMaxSendFragment(size: number): boolean;
5580
5581 /**
5582 * events.EventEmitter
5583 * 1. OCSPResponse
5584 * 2. secureConnect
5585 */
5586 addListener(event: string, listener: (...args: any[]) => void): this;
5587 addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
5588 addListener(event: "secureConnect", listener: () => void): this;
5589
5590 emit(event: string | symbol, ...args: any[]): boolean;
5591 emit(event: "OCSPResponse", response: Buffer): boolean;
5592 emit(event: "secureConnect"): boolean;
5593
5594 on(event: string, listener: (...args: any[]) => void): this;
5595 on(event: "OCSPResponse", listener: (response: Buffer) => void): this;
5596 on(event: "secureConnect", listener: () => void): this;
5597
5598 once(event: string, listener: (...args: any[]) => void): this;
5599 once(event: "OCSPResponse", listener: (response: Buffer) => void): this;
5600 once(event: "secureConnect", listener: () => void): this;
5601
5602 prependListener(event: string, listener: (...args: any[]) => void): this;
5603 prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
5604 prependListener(event: "secureConnect", listener: () => void): this;
5605
5606 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
5607 prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this;
5608 prependOnceListener(event: "secureConnect", listener: () => void): this;
5609 }
5610
5611 export interface TlsOptions extends SecureContextOptions {
5612 handshakeTimeout?: number;
5613 requestCert?: boolean;
5614 rejectUnauthorized?: boolean;
5615 NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
5616 ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
5617 SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void;
5618 sessionTimeout?: number;
5619 ticketKeys?: Buffer;
5620 }
5621
5622 export interface ConnectionOptions extends SecureContextOptions {
5623 host?: string;
5624 port?: number;
5625 path?: string; // Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored.
5626 socket?: net.Socket; // Establish secure connection on a given socket rather than creating a new socket
5627 rejectUnauthorized?: boolean; // Defaults to true
5628 NPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
5629 ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
5630 checkServerIdentity?: typeof checkServerIdentity;
5631 servername?: string; // SNI TLS Extension
5632 session?: Buffer;
5633 minDHSize?: number;
5634 secureContext?: SecureContext; // If not provided, the entire ConnectionOptions object will be passed to tls.createSecureContext()
5635 lookup?: net.LookupFunction;
5636 }
5637
5638 export class Server extends net.Server {
5639 addContext(hostName: string, credentials: {
5640 key: string;
5641 cert: string;
5642 ca: string;
5643 }): void;
5644
5645 /**
5646 * events.EventEmitter
5647 * 1. tlsClientError
5648 * 2. newSession
5649 * 3. OCSPRequest
5650 * 4. resumeSession
5651 * 5. secureConnection
5652 */
5653 addListener(event: string, listener: (...args: any[]) => void): this;
5654 addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
5655 addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
5656 addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
5657 addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
5658 addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
5659
5660 emit(event: string | symbol, ...args: any[]): boolean;
5661 emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean;
5662 emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean;
5663 emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean;
5664 emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean;
5665 emit(event: "secureConnection", tlsSocket: TLSSocket): boolean;
5666
5667 on(event: string, listener: (...args: any[]) => void): this;
5668 on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
5669 on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
5670 on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
5671 on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
5672 on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
5673
5674 once(event: string, listener: (...args: any[]) => void): this;
5675 once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
5676 once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
5677 once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
5678 once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
5679 once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
5680
5681 prependListener(event: string, listener: (...args: any[]) => void): this;
5682 prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
5683 prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
5684 prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
5685 prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
5686 prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
5687
5688 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
5689 prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this;
5690 prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this;
5691 prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this;
5692 prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
5693 prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this;
5694 }
5695
5696 export interface SecurePair {
5697 encrypted: any;
5698 cleartext: any;
5699 }
5700
5701 export interface SecureContextOptions {
5702 pfx?: string | Buffer | Array<string | Buffer | Object>;
5703 key?: string | Buffer | Array<Buffer | Object>;
5704 passphrase?: string;
5705 cert?: string | Buffer | Array<string | Buffer>;
5706 ca?: string | Buffer | Array<string | Buffer>;
5707 ciphers?: string;
5708 honorCipherOrder?: boolean;
5709 ecdhCurve?: string;
5710 clientCertEngine?: string;
5711 crl?: string | Buffer | Array<string | Buffer>;
5712 dhparam?: string | Buffer;
5713 secureOptions?: number; // Value is a numeric bitmask of the `SSL_OP_*` options
5714 secureProtocol?: string; // SSL Method, e.g. SSLv23_method
5715 sessionIdContext?: string;
5716 }
5717
5718 export interface SecureContext {
5719 context: any;
5720 }
5721
5722 /*
5723 * Verifies the certificate `cert` is issued to host `host`.
5724 * @host The hostname to verify the certificate against
5725 * @cert PeerCertificate representing the peer's certificate
5726 *
5727 * Returns Error object, populating it with the reason, host and cert on failure. On success, returns undefined.
5728 */
5729 export function checkServerIdentity(host: string, cert: PeerCertificate): Error | undefined;
5730 export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server;
5731 export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket;
5732 export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
5733 export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
5734 export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
5735 export function createSecureContext(details: SecureContextOptions): SecureContext;
5736 export function getCiphers(): string[];
5737
5738 export var DEFAULT_ECDH_CURVE: string;
5739}
5740
5741declare module "crypto" {
5742 import * as stream from "stream";
5743
5744 export interface Certificate {
5745 exportChallenge(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
5746 exportPublicKey(spkac: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
5747 verifySpkac(spkac: Buffer | NodeJS.TypedArray | DataView): boolean;
5748 }
5749 export var Certificate: {
5750 new(): Certificate;
5751 (): Certificate;
5752 };
5753
5754 /** @deprecated since v10.0.0 */
5755 export var fips: boolean;
5756
5757 export interface CredentialDetails {
5758 pfx: string;
5759 key: string;
5760 passphrase: string;
5761 cert: string;
5762 ca: string | string[];
5763 crl: string | string[];
5764 ciphers: string;
5765 }
5766 export interface Credentials { context?: any; }
5767 export function createCredentials(details: CredentialDetails): Credentials;
5768 export function createHash(algorithm: string, options?: stream.TransformOptions): Hash;
5769 export function createHmac(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Hmac;
5770
5771 type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
5772 type HexBase64Latin1Encoding = "latin1" | "hex" | "base64";
5773 type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary";
5774 type HexBase64BinaryEncoding = "binary" | "base64" | "hex";
5775 type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
5776
5777 export interface Hash extends NodeJS.ReadWriteStream {
5778 update(data: string | Buffer | NodeJS.TypedArray | DataView): Hash;
5779 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hash;
5780 digest(): Buffer;
5781 digest(encoding: HexBase64Latin1Encoding): string;
5782 }
5783 export interface Hmac extends NodeJS.ReadWriteStream {
5784 update(data: string | Buffer | NodeJS.TypedArray | DataView): Hmac;
5785 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Hmac;
5786 digest(): Buffer;
5787 digest(encoding: HexBase64Latin1Encoding): string;
5788 }
5789 export type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
5790 export type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
5791 export interface CipherCCMOptions extends stream.TransformOptions {
5792 authTagLength: number;
5793 }
5794 export interface CipherGCMOptions extends stream.TransformOptions {
5795 authTagLength?: number;
5796 }
5797 /** @deprecated since v10.0.0 use createCipheriv() */
5798 export function createCipher(algorithm: string, password: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Cipher;
5799 export function createCipher(algorithm: CipherCCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): CipherCCM;
5800 export function createCipher(algorithm: CipherGCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherGCMOptions): CipherGCM;
5801
5802 export function createCipheriv(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Cipher;
5803 export function createCipheriv(algorithm: CipherGCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): CipherCCM;
5804 export function createCipheriv(algorithm: CipherGCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options: CipherGCMOptions): CipherGCM;
5805
5806 export interface Cipher extends NodeJS.ReadWriteStream {
5807 update(data: string | Buffer | NodeJS.TypedArray | DataView): Buffer;
5808 update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
5809 update(data: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64BinaryEncoding): string;
5810 update(data: Buffer | NodeJS.TypedArray | DataView, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string;
5811 // second arg ignored
5812 update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string;
5813 final(): Buffer;
5814 final(output_encoding: string): string;
5815 setAutoPadding(auto_padding?: boolean): this;
5816 // getAuthTag(): Buffer;
5817 // setAAD(buffer: Buffer): this; // docs only say buffer
5818 }
5819 export interface CipherCCM extends Cipher {
5820 setAAD(buffer: Buffer, options: { plainTextLength: number }): this;
5821 getAuthTag(): Buffer;
5822 }
5823 export interface CipherGCM extends Cipher {
5824 setAAD(buffer: Buffer, options?: { plainTextLength: number }): this;
5825 getAuthTag(): Buffer;
5826 }
5827 /** @deprecated since v10.0.0 use createCipheriv() */
5828 export function createDecipher(algorithm: string, password: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Decipher;
5829 export function createDecipher(algorithm: CipherCCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): DecipherCCM;
5830 export function createDecipher(algorithm: CipherGCMTypes, password: string | Buffer | NodeJS.TypedArray | DataView, options: CipherGCMOptions): DecipherGCM;
5831
5832 export function createDecipheriv(algorithm: string, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options?: stream.TransformOptions): Decipher;
5833 export function createDecipheriv(algorithm: CipherCCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options: CipherCCMOptions): DecipherCCM;
5834 export function createDecipheriv(algorithm: CipherGCMTypes, key: string | Buffer | NodeJS.TypedArray | DataView, iv: string | Buffer | NodeJS.TypedArray | DataView, options: CipherGCMOptions): DecipherGCM;
5835
5836 export interface Decipher extends NodeJS.ReadWriteStream {
5837 update(data: Buffer | NodeJS.TypedArray | DataView): Buffer;
5838 update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
5839 update(data: Buffer | NodeJS.TypedArray | DataView, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string;
5840 // second arg is ignored
5841 update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string;
5842 final(): Buffer;
5843 final(output_encoding: string): string;
5844 setAutoPadding(auto_padding?: boolean): this;
5845 // setAuthTag(tag: Buffer | NodeJS.TypedArray | DataView): this;
5846 // setAAD(buffer: Buffer | NodeJS.TypedArray | DataView): this;
5847 }
5848 export interface DecipherCCM extends Decipher {
5849 setAuthTag(buffer: Buffer | NodeJS.TypedArray | DataView, options: { plainTextLength: number }): this;
5850 setAAD(buffer: Buffer | NodeJS.TypedArray | DataView): this;
5851 }
5852 export interface DecipherGCM extends Decipher {
5853 setAuthTag(buffer: Buffer | NodeJS.TypedArray | DataView, options?: { plainTextLength: number }): this;
5854 setAAD(buffer: Buffer | NodeJS.TypedArray | DataView): this;
5855 }
5856
5857 export function createSign(algorithm: string, options?: stream.WritableOptions): Signer;
5858 export interface Signer extends NodeJS.WritableStream {
5859 update(data: string | Buffer | NodeJS.TypedArray | DataView): Signer;
5860 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Signer;
5861 sign(private_key: string | { key: string; passphrase: string }): Buffer;
5862 sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string;
5863 }
5864 export function createVerify(algorith: string, options?: stream.WritableOptions): Verify;
5865 export interface Verify extends NodeJS.WritableStream {
5866 update(data: string | Buffer | NodeJS.TypedArray | DataView): Verify;
5867 update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
5868 verify(object: string | Object, signature: Buffer | NodeJS.TypedArray | DataView): boolean;
5869 verify(object: string | Object, signature: string, signature_format: HexBase64Latin1Encoding): boolean;
5870 // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
5871 // The signature field accepts a TypedArray type, but it is only available starting ES2017
5872 }
5873 export function createDiffieHellman(prime_length: number, generator?: number | Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
5874 export function createDiffieHellman(prime: Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
5875 export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
5876 export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer | NodeJS.TypedArray | DataView): DiffieHellman;
5877 export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
5878 export interface DiffieHellman {
5879 generateKeys(): Buffer;
5880 generateKeys(encoding: HexBase64Latin1Encoding): string;
5881 computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView): Buffer;
5882 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
5883 computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64Latin1Encoding): string;
5884 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
5885 getPrime(): Buffer;
5886 getPrime(encoding: HexBase64Latin1Encoding): string;
5887 getGenerator(): Buffer;
5888 getGenerator(encoding: HexBase64Latin1Encoding): string;
5889 getPublicKey(): Buffer;
5890 getPublicKey(encoding: HexBase64Latin1Encoding): string;
5891 getPrivateKey(): Buffer;
5892 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
5893 setPublicKey(public_key: Buffer | NodeJS.TypedArray | DataView): void;
5894 setPublicKey(public_key: string, encoding: string): void;
5895 setPrivateKey(private_key: Buffer | NodeJS.TypedArray | DataView): void;
5896 setPrivateKey(private_key: string, encoding: string): void;
5897 verifyError: number;
5898 }
5899 export function getDiffieHellman(group_name: string): DiffieHellman;
5900 export function pbkdf2(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, iterations: number, keylen: number, digest: string, callback: (err: Error | null, derivedKey: Buffer) => any): void;
5901 export function pbkdf2Sync(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, iterations: number, keylen: number, digest: string): Buffer;
5902
5903 export function randomBytes(size: number): Buffer;
5904 export function randomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
5905 export function pseudoRandomBytes(size: number): Buffer;
5906 export function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
5907
5908 export function randomFillSync<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset?: number, size?: number): T;
5909 export function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
5910 export function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
5911 export function randomFill<T extends Buffer | NodeJS.TypedArray | DataView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
5912
5913 export interface ScryptOptions {
5914 N?: number;
5915 r?: number;
5916 p?: number;
5917 maxmem?: number;
5918 }
5919 export function scrypt(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, keylen: number, callback: (err: Error | null, derivedKey: Buffer) => void): void;
5920 export function scrypt(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, keylen: number, options: ScryptOptions, callback: (err: Error | null, derivedKey: Buffer) => void): void;
5921 export function scryptSync(password: string | Buffer | NodeJS.TypedArray | DataView, salt: string | Buffer | NodeJS.TypedArray | DataView, keylen: number, options?: ScryptOptions): Buffer;
5922
5923 export interface RsaPublicKey {
5924 key: string;
5925 padding?: number;
5926 }
5927 export interface RsaPrivateKey {
5928 key: string;
5929 passphrase?: string;
5930 padding?: number;
5931 }
5932 export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
5933 export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
5934 export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
5935 export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer | NodeJS.TypedArray | DataView): Buffer;
5936 export function getCiphers(): string[];
5937 export function getCurves(): string[];
5938 export function getHashes(): string[];
5939 export class ECDH {
5940 static convertKey(key: string | Buffer | NodeJS.TypedArray | DataView, curve: string, inputEncoding?: HexBase64Latin1Encoding, outputEncoding?: "latin1" | "hex" | "base64", format?: "uncompressed" | "compressed" | "hybrid"): Buffer | string;
5941 generateKeys(): Buffer;
5942 generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
5943 computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView): Buffer;
5944 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
5945 computeSecret(other_public_key: Buffer | NodeJS.TypedArray | DataView, output_encoding: HexBase64Latin1Encoding): string;
5946 computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
5947 getPrivateKey(): Buffer;
5948 getPrivateKey(encoding: HexBase64Latin1Encoding): string;
5949 getPublicKey(): Buffer;
5950 getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
5951 setPrivateKey(private_key: Buffer | NodeJS.TypedArray | DataView): void;
5952 setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
5953 }
5954 export function createECDH(curve_name: string): ECDH;
5955 export function timingSafeEqual(a: Buffer | NodeJS.TypedArray | DataView, b: Buffer | NodeJS.TypedArray | DataView): boolean;
5956 /** @deprecated since v10.0.0 */
5957 export var DEFAULT_ENCODING: string;
5958}
5959
5960declare module "stream" {
5961 import * as events from "events";
5962
5963 class internal extends events.EventEmitter {
5964 pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
5965 }
5966
5967 namespace internal {
5968 export class Stream extends internal { }
5969
5970 export interface ReadableOptions {
5971 highWaterMark?: number;
5972 encoding?: string;
5973 objectMode?: boolean;
5974 read?: (this: Readable, size?: number) => any;
5975 destroy?: (error: Error | null, callback: (error?: Error) => void) => void;
5976 }
5977
5978 export class Readable extends Stream implements NodeJS.ReadableStream {
5979 readable: boolean;
5980 readonly readableHighWaterMark: number;
5981 readonly readableLength: number;
5982 constructor(opts?: ReadableOptions);
5983 _read(size: number): void;
5984 read(size?: number): any;
5985 setEncoding(encoding: string): this;
5986 pause(): this;
5987 resume(): this;
5988 isPaused(): boolean;
5989 unpipe<T extends NodeJS.WritableStream>(destination?: T): this;
5990 unshift(chunk: any): void;
5991 wrap(oldStream: NodeJS.ReadableStream): this;
5992 push(chunk: any, encoding?: string): boolean;
5993 _destroy(error: Error | null, callback: (error?: Error) => void): void;
5994 destroy(error?: Error): void;
5995
5996 /**
5997 * Event emitter
5998 * The defined events on documents including:
5999 * 1. close
6000 * 2. data
6001 * 3. end
6002 * 4. readable
6003 * 5. error
6004 */
6005 addListener(event: string, listener: (...args: any[]) => void): this;
6006 addListener(event: "close", listener: () => void): this;
6007 addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
6008 addListener(event: "end", listener: () => void): this;
6009 addListener(event: "readable", listener: () => void): this;
6010 addListener(event: "error", listener: (err: Error) => void): this;
6011
6012 emit(event: string | symbol, ...args: any[]): boolean;
6013 emit(event: "close"): boolean;
6014 emit(event: "data", chunk: Buffer | string): boolean;
6015 emit(event: "end"): boolean;
6016 emit(event: "readable"): boolean;
6017 emit(event: "error", err: Error): boolean;
6018
6019 on(event: string, listener: (...args: any[]) => void): this;
6020 on(event: "close", listener: () => void): this;
6021 on(event: "data", listener: (chunk: Buffer | string) => void): this;
6022 on(event: "end", listener: () => void): this;
6023 on(event: "readable", listener: () => void): this;
6024 on(event: "error", listener: (err: Error) => void): this;
6025
6026 once(event: string, listener: (...args: any[]) => void): this;
6027 once(event: "close", listener: () => void): this;
6028 once(event: "data", listener: (chunk: Buffer | string) => void): this;
6029 once(event: "end", listener: () => void): this;
6030 once(event: "readable", listener: () => void): this;
6031 once(event: "error", listener: (err: Error) => void): this;
6032
6033 prependListener(event: string, listener: (...args: any[]) => void): this;
6034 prependListener(event: "close", listener: () => void): this;
6035 prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
6036 prependListener(event: "end", listener: () => void): this;
6037 prependListener(event: "readable", listener: () => void): this;
6038 prependListener(event: "error", listener: (err: Error) => void): this;
6039
6040 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
6041 prependOnceListener(event: "close", listener: () => void): this;
6042 prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
6043 prependOnceListener(event: "end", listener: () => void): this;
6044 prependOnceListener(event: "readable", listener: () => void): this;
6045 prependOnceListener(event: "error", listener: (err: Error) => void): this;
6046
6047 removeListener(event: string, listener: (...args: any[]) => void): this;
6048 removeListener(event: "close", listener: () => void): this;
6049 removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
6050 removeListener(event: "end", listener: () => void): this;
6051 removeListener(event: "readable", listener: () => void): this;
6052 removeListener(event: "error", listener: (err: Error) => void): this;
6053
6054 [Symbol.asyncIterator](): AsyncIterableIterator<Buffer | string>;
6055 }
6056
6057 export interface WritableOptions {
6058 highWaterMark?: number;
6059 decodeStrings?: boolean;
6060 objectMode?: boolean;
6061 write?: (chunk: any, encoding: string, callback: Function) => any;
6062 writev?: (chunks: Array<{ chunk: any, encoding: string }>, callback: Function) => any;
6063 destroy?: (error: Error | null, callback: (error?: Error) => void) => void;
6064 final?: (callback: (error?: Error) => void) => void;
6065 }
6066
6067 export class Writable extends Stream implements NodeJS.WritableStream {
6068 writable: boolean;
6069 readonly writableHighWaterMark: number;
6070 readonly writableLength: number;
6071 constructor(opts?: WritableOptions);
6072 _write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
6073 _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
6074 _destroy(error: Error | null, callback: (error?: Error) => void): void;
6075 _final(callback: Function): void;
6076 write(chunk: any, cb?: Function): boolean;
6077 write(chunk: any, encoding?: string, cb?: Function): boolean;
6078 setDefaultEncoding(encoding: string): this;
6079 end(cb?: Function): void;
6080 end(chunk: any, cb?: Function): void;
6081 end(chunk: any, encoding?: string, cb?: Function): void;
6082 cork(): void;
6083 uncork(): void;
6084 destroy(error?: Error): void;
6085
6086 /**
6087 * Event emitter
6088 * The defined events on documents including:
6089 * 1. close
6090 * 2. drain
6091 * 3. error
6092 * 4. finish
6093 * 5. pipe
6094 * 6. unpipe
6095 */
6096 addListener(event: string, listener: (...args: any[]) => void): this;
6097 addListener(event: "close", listener: () => void): this;
6098 addListener(event: "drain", listener: () => void): this;
6099 addListener(event: "error", listener: (err: Error) => void): this;
6100 addListener(event: "finish", listener: () => void): this;
6101 addListener(event: "pipe", listener: (src: Readable) => void): this;
6102 addListener(event: "unpipe", listener: (src: Readable) => void): this;
6103
6104 emit(event: string | symbol, ...args: any[]): boolean;
6105 emit(event: "close"): boolean;
6106 emit(event: "drain", chunk: Buffer | string): boolean;
6107 emit(event: "error", err: Error): boolean;
6108 emit(event: "finish"): boolean;
6109 emit(event: "pipe", src: Readable): boolean;
6110 emit(event: "unpipe", src: Readable): boolean;
6111
6112 on(event: string, listener: (...args: any[]) => void): this;
6113 on(event: "close", listener: () => void): this;
6114 on(event: "drain", listener: () => void): this;
6115 on(event: "error", listener: (err: Error) => void): this;
6116 on(event: "finish", listener: () => void): this;
6117 on(event: "pipe", listener: (src: Readable) => void): this;
6118 on(event: "unpipe", listener: (src: Readable) => void): this;
6119
6120 once(event: string, listener: (...args: any[]) => void): this;
6121 once(event: "close", listener: () => void): this;
6122 once(event: "drain", listener: () => void): this;
6123 once(event: "error", listener: (err: Error) => void): this;
6124 once(event: "finish", listener: () => void): this;
6125 once(event: "pipe", listener: (src: Readable) => void): this;
6126 once(event: "unpipe", listener: (src: Readable) => void): this;
6127
6128 prependListener(event: string, listener: (...args: any[]) => void): this;
6129 prependListener(event: "close", listener: () => void): this;
6130 prependListener(event: "drain", listener: () => void): this;
6131 prependListener(event: "error", listener: (err: Error) => void): this;
6132 prependListener(event: "finish", listener: () => void): this;
6133 prependListener(event: "pipe", listener: (src: Readable) => void): this;
6134 prependListener(event: "unpipe", listener: (src: Readable) => void): this;
6135
6136 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
6137 prependOnceListener(event: "close", listener: () => void): this;
6138 prependOnceListener(event: "drain", listener: () => void): this;
6139 prependOnceListener(event: "error", listener: (err: Error) => void): this;
6140 prependOnceListener(event: "finish", listener: () => void): this;
6141 prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
6142 prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
6143
6144 removeListener(event: string, listener: (...args: any[]) => void): this;
6145 removeListener(event: "close", listener: () => void): this;
6146 removeListener(event: "drain", listener: () => void): this;
6147 removeListener(event: "error", listener: (err: Error) => void): this;
6148 removeListener(event: "finish", listener: () => void): this;
6149 removeListener(event: "pipe", listener: (src: Readable) => void): this;
6150 removeListener(event: "unpipe", listener: (src: Readable) => void): this;
6151 }
6152
6153 export interface DuplexOptions extends ReadableOptions, WritableOptions {
6154 allowHalfOpen?: boolean;
6155 readableObjectMode?: boolean;
6156 writableObjectMode?: boolean;
6157 }
6158
6159 // Note: Duplex extends both Readable and Writable.
6160 export class Duplex extends Readable implements Writable {
6161 writable: boolean;
6162 readonly writableHighWaterMark: number;
6163 readonly writableLength: number;
6164 constructor(opts?: DuplexOptions);
6165 _write(chunk: any, encoding: string, callback: (err?: Error) => void): void;
6166 _writev?(chunks: Array<{ chunk: any, encoding: string }>, callback: (err?: Error) => void): void;
6167 _destroy(error: Error | null, callback: (error?: Error) => void): void;
6168 _final(callback: Function): void;
6169 write(chunk: any, cb?: Function): boolean;
6170 write(chunk: any, encoding?: string, cb?: Function): boolean;
6171 setDefaultEncoding(encoding: string): this;
6172 end(cb?: Function): void;
6173 end(chunk: any, cb?: Function): void;
6174 end(chunk: any, encoding?: string, cb?: Function): void;
6175 cork(): void;
6176 uncork(): void;
6177 }
6178
6179 type TransformCallback = (err?: Error, data?: any) => void;
6180
6181 export interface TransformOptions extends DuplexOptions {
6182 transform?: (chunk: any, encoding: string, callback: TransformCallback) => any;
6183 flush?: (callback: TransformCallback) => any;
6184 }
6185
6186 export class Transform extends Duplex {
6187 constructor(opts?: TransformOptions);
6188 _transform(chunk: any, encoding: string, callback: TransformCallback): void;
6189 destroy(error?: Error): void;
6190 }
6191
6192 export class PassThrough extends Transform { }
6193
6194 export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException) => void): T;
6195 export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException) => void): T;
6196 export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: T, callback?: (err: NodeJS.ErrnoException) => void): T;
6197 export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: NodeJS.ReadWriteStream, stream5: T, callback?: (err: NodeJS.ErrnoException) => void): T;
6198 export function pipeline(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>, callback?: (err: NodeJS.ErrnoException) => void): NodeJS.WritableStream;
6199 export function pipeline(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | ((err: NodeJS.ErrnoException) => void)>): NodeJS.WritableStream;
6200 export namespace pipeline {
6201 export function __promisify__<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T): Promise<void>;
6202 export function __promisify__<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T): Promise<void>;
6203 export function __promisify__<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: T): Promise<void>;
6204 export function __promisify__<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: NodeJS.ReadWriteStream, stream5: T): Promise<void>;
6205 export function __promisify__(streams: Array<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>): Promise<void>;
6206 export function __promisify__(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>): Promise<void>;
6207 }
6208 }
6209
6210 export = internal;
6211}
6212
6213declare module "util" {
6214 export interface InspectOptions extends NodeJS.InspectOptions { }
6215 export function format(format: any, ...param: any[]): string;
6216 /** @deprecated since v0.11.3 - use `console.error()` instead. */
6217 export function debug(string: string): void;
6218 /** @deprecated since v0.11.3 - use `console.error()` instead. */
6219 export function error(...param: any[]): void;
6220 /** @deprecated since v0.11.3 - use `console.log()` instead. */
6221 export function puts(...param: any[]): void;
6222 /** @deprecated since v0.11.3 - use `console.log()` instead. */
6223 export function print(...param: any[]): void;
6224 /** @deprecated since v0.11.3 - use a third party module instead. */
6225 export function log(string: string): void;
6226 export var inspect: {
6227 (object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
6228 (object: any, options: InspectOptions): string;
6229 colors: {
6230 [color: string]: [number, number] | undefined
6231 }
6232 styles: {
6233 [style: string]: string | undefined
6234 }
6235 defaultOptions: InspectOptions;
6236 custom: symbol;
6237 };
6238 /** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
6239 export function isArray(object: any): object is any[];
6240 /** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
6241 export function isRegExp(object: any): object is RegExp;
6242 /** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
6243 export function isDate(object: any): object is Date;
6244 /** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
6245 export function isError(object: any): object is Error;
6246 export function inherits(constructor: any, superConstructor: any): void;
6247 export function debuglog(key: string): (msg: string, ...param: any[]) => void;
6248 /** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
6249 export function isBoolean(object: any): object is boolean;
6250 /** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
6251 export function isBuffer(object: any): object is Buffer;
6252 /** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
6253 export function isFunction(object: any): boolean;
6254 /** @deprecated since v4.0.0 - use `value === null` instead. */
6255 export function isNull(object: any): object is null;
6256 /** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
6257 export function isNullOrUndefined(object: any): object is null | undefined;
6258 /** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
6259 export function isNumber(object: any): object is number;
6260 /** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
6261 export function isObject(object: any): boolean;
6262 /** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
6263 export function isPrimitive(object: any): boolean;
6264 /** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
6265 export function isString(object: any): object is string;
6266 /** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
6267 export function isSymbol(object: any): object is symbol;
6268 /** @deprecated since v4.0.0 - use `value === undefined` instead. */
6269 export function isUndefined(object: any): object is undefined;
6270 export function deprecate<T extends Function>(fn: T, message: string): T;
6271 export function isDeepStrictEqual(val1: any, val2: any): boolean;
6272
6273 export interface CustomPromisify<TCustom extends Function> extends Function {
6274 __promisify__: TCustom;
6275 }
6276
6277 export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
6278 export function callbackify<TResult>(fn: () => Promise<TResult>): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6279 export function callbackify<T1>(fn: (arg1: T1) => Promise<void>): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
6280 export function callbackify<T1, TResult>(fn: (arg1: T1) => Promise<TResult>): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6281 export function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
6282 export function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6283 export function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
6284 export function callbackify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6285 export function callbackify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
6286 export function callbackify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6287 export function callbackify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
6288 export function callbackify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6289 export function callbackify<T1, T2, T3, T4, T5, T6>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
6290 export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
6291
6292 export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
6293 export function promisify<TResult>(fn: (callback: (err: Error | null, result: TResult) => void) => void): () => Promise<TResult>;
6294 export function promisify(fn: (callback: (err: Error | null) => void) => void): () => Promise<void>;
6295 export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
6296 export function promisify<T1>(fn: (arg1: T1, callback: (err: Error | null) => void) => void): (arg1: T1) => Promise<void>;
6297 export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
6298 export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
6299 export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
6300 export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
6301 export function promisify<T1, T2, T3, T4, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
6302 export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
6303 export function promisify<T1, T2, T3, T4, T5, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
6304 export function promisify<T1, T2, T3, T4, T5>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: Error | null) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
6305 export function promisify(fn: Function): Function;
6306 export namespace promisify {
6307 const custom: symbol;
6308 }
6309
6310 export namespace types {
6311 export function isAnyArrayBuffer(object: any): boolean;
6312 export function isArgumentsObject(object: any): object is IArguments;
6313 export function isArrayBuffer(object: any): object is ArrayBuffer;
6314 export function isAsyncFunction(object: any): boolean;
6315 export function isBooleanObject(object: any): object is Boolean;
6316 export function isDataView(object: any): object is DataView;
6317 export function isDate(object: any): object is Date;
6318 export function isExternal(object: any): boolean;
6319 export function isFloat32Array(object: any): object is Float32Array;
6320 export function isFloat64Array(object: any): object is Float64Array;
6321 export function isGeneratorFunction(object: any): boolean;
6322 export function isGeneratorObject(object: any): boolean;
6323 export function isInt8Array(object: any): object is Int8Array;
6324 export function isInt16Array(object: any): object is Int16Array;
6325 export function isInt32Array(object: any): object is Int32Array;
6326 export function isMap(object: any): boolean;
6327 export function isMapIterator(object: any): boolean;
6328 export function isNativeError(object: any): object is Error;
6329 export function isNumberObject(object: any): object is Number;
6330 export function isPromise(object: any): boolean;
6331 export function isProxy(object: any): boolean;
6332 export function isRegExp(object: any): object is RegExp;
6333 export function isSet(object: any): boolean;
6334 export function isSetIterator(object: any): boolean;
6335 export function isSharedArrayBuffer(object: any): boolean;
6336 export function isStringObject(object: any): boolean;
6337 export function isSymbolObject(object: any): boolean;
6338 export function isTypedArray(object: any): object is NodeJS.TypedArray;
6339 export function isUint8Array(object: any): object is Uint8Array;
6340 export function isUint8ClampedArray(object: any): object is Uint8ClampedArray;
6341 export function isUint16Array(object: any): object is Uint16Array;
6342 export function isUint32Array(object: any): object is Uint32Array;
6343 export function isWeakMap(object: any): boolean;
6344 export function isWeakSet(object: any): boolean;
6345 export function isWebAssemblyCompiledModule(object: any): boolean;
6346 }
6347
6348 export class TextDecoder {
6349 readonly encoding: string;
6350 readonly fatal: boolean;
6351 readonly ignoreBOM: boolean;
6352 constructor(
6353 encoding?: string,
6354 options?: { fatal?: boolean; ignoreBOM?: boolean }
6355 );
6356 decode(
6357 input?: NodeJS.TypedArray | DataView | ArrayBuffer | null,
6358 options?: { stream?: boolean }
6359 ): string;
6360 }
6361
6362 export class TextEncoder {
6363 readonly encoding: string;
6364 constructor();
6365 encode(input?: string): Uint8Array;
6366 }
6367}
6368
6369declare module "assert" {
6370 function internal(value: any, message?: string): void;
6371 namespace internal {
6372 export class AssertionError implements Error {
6373 name: string;
6374 message: string;
6375 actual: any;
6376 expected: any;
6377 operator: string;
6378 generatedMessage: boolean;
6379
6380 constructor(options?: {
6381 message?: string; actual?: any; expected?: any;
6382 operator?: string; stackStartFunction?: Function
6383 });
6384 }
6385
6386 export function fail(message: string): never;
6387 /** @deprecated since v10.0.0 */
6388 export function fail(actual: any, expected: any, message?: string, operator?: string): never;
6389 export function ok(value: any, message?: string): void;
6390 /** @deprecated use strictEqual() */
6391 export function equal(actual: any, expected: any, message?: string): void;
6392 /** @deprecated use notStrictEqual() */
6393 export function notEqual(actual: any, expected: any, message?: string): void;
6394 /** @deprecated use deepStrictEqual() */
6395 export function deepEqual(actual: any, expected: any, message?: string): void;
6396 /** @deprecated use notDeepStrictEqual() */
6397 export function notDeepEqual(acutal: any, expected: any, message?: string): void;
6398 export function strictEqual(actual: any, expected: any, message?: string): void;
6399 export function notStrictEqual(actual: any, expected: any, message?: string): void;
6400 export function deepStrictEqual(actual: any, expected: any, message?: string): void;
6401 export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
6402
6403 export function throws(block: Function, message?: string): void;
6404 export function throws(block: Function, error: Function, message?: string): void;
6405 export function throws(block: Function, error: RegExp, message?: string): void;
6406 export function throws(block: Function, error: (err: any) => boolean, message?: string): void;
6407
6408 export function doesNotThrow(block: Function, message?: string): void;
6409 export function doesNotThrow(block: Function, error: Function, message?: string): void;
6410 export function doesNotThrow(block: Function, error: RegExp, message?: string): void;
6411 export function doesNotThrow(block: Function, error: (err: any) => boolean, message?: string): void;
6412
6413 export function ifError(value: any): void;
6414
6415 export function rejects(block: Function | Promise<any>, message?: string): Promise<void>;
6416 export function rejects(block: Function | Promise<any>, error: Function | RegExp | Object | Error, message?: string): Promise<void>;
6417 export function doesNotReject(block: Function | Promise<any>, message?: string): Promise<void>;
6418 export function doesNotReject(block: Function | Promise<any>, error: Function | RegExp | Object | Error, message?: string): Promise<void>;
6419
6420 export var strict: typeof internal;
6421 }
6422
6423 export = internal;
6424}
6425
6426declare module "tty" {
6427 import * as net from "net";
6428
6429 export function isatty(fd: number): boolean;
6430 export class ReadStream extends net.Socket {
6431 isRaw: boolean;
6432 setRawMode(mode: boolean): void;
6433 isTTY: boolean;
6434 }
6435 export class WriteStream extends net.Socket {
6436 columns: number;
6437 rows: number;
6438 isTTY: boolean;
6439 }
6440}
6441
6442declare module "domain" {
6443 import * as events from "events";
6444
6445 export class Domain extends events.EventEmitter implements NodeJS.Domain {
6446 run(fn: Function): void;
6447 add(emitter: events.EventEmitter): void;
6448 remove(emitter: events.EventEmitter): void;
6449 bind(cb: (err: Error, data: any) => any): any;
6450 intercept(cb: (data: any) => any): any;
6451 members: any[];
6452 enter(): void;
6453 exit(): void;
6454 }
6455
6456 export function create(): Domain;
6457}
6458
6459declare module "constants" {
6460 export var E2BIG: number;
6461 export var EACCES: number;
6462 export var EADDRINUSE: number;
6463 export var EADDRNOTAVAIL: number;
6464 export var EAFNOSUPPORT: number;
6465 export var EAGAIN: number;
6466 export var EALREADY: number;
6467 export var EBADF: number;
6468 export var EBADMSG: number;
6469 export var EBUSY: number;
6470 export var ECANCELED: number;
6471 export var ECHILD: number;
6472 export var ECONNABORTED: number;
6473 export var ECONNREFUSED: number;
6474 export var ECONNRESET: number;
6475 export var EDEADLK: number;
6476 export var EDESTADDRREQ: number;
6477 export var EDOM: number;
6478 export var EEXIST: number;
6479 export var EFAULT: number;
6480 export var EFBIG: number;
6481 export var EHOSTUNREACH: number;
6482 export var EIDRM: number;
6483 export var EILSEQ: number;
6484 export var EINPROGRESS: number;
6485 export var EINTR: number;
6486 export var EINVAL: number;
6487 export var EIO: number;
6488 export var EISCONN: number;
6489 export var EISDIR: number;
6490 export var ELOOP: number;
6491 export var EMFILE: number;
6492 export var EMLINK: number;
6493 export var EMSGSIZE: number;
6494 export var ENAMETOOLONG: number;
6495 export var ENETDOWN: number;
6496 export var ENETRESET: number;
6497 export var ENETUNREACH: number;
6498 export var ENFILE: number;
6499 export var ENOBUFS: number;
6500 export var ENODATA: number;
6501 export var ENODEV: number;
6502 export var ENOENT: number;
6503 export var ENOEXEC: number;
6504 export var ENOLCK: number;
6505 export var ENOLINK: number;
6506 export var ENOMEM: number;
6507 export var ENOMSG: number;
6508 export var ENOPROTOOPT: number;
6509 export var ENOSPC: number;
6510 export var ENOSR: number;
6511 export var ENOSTR: number;
6512 export var ENOSYS: number;
6513 export var ENOTCONN: number;
6514 export var ENOTDIR: number;
6515 export var ENOTEMPTY: number;
6516 export var ENOTSOCK: number;
6517 export var ENOTSUP: number;
6518 export var ENOTTY: number;
6519 export var ENXIO: number;
6520 export var EOPNOTSUPP: number;
6521 export var EOVERFLOW: number;
6522 export var EPERM: number;
6523 export var EPIPE: number;
6524 export var EPROTO: number;
6525 export var EPROTONOSUPPORT: number;
6526 export var EPROTOTYPE: number;
6527 export var ERANGE: number;
6528 export var EROFS: number;
6529 export var ESPIPE: number;
6530 export var ESRCH: number;
6531 export var ETIME: number;
6532 export var ETIMEDOUT: number;
6533 export var ETXTBSY: number;
6534 export var EWOULDBLOCK: number;
6535 export var EXDEV: number;
6536 export var WSAEINTR: number;
6537 export var WSAEBADF: number;
6538 export var WSAEACCES: number;
6539 export var WSAEFAULT: number;
6540 export var WSAEINVAL: number;
6541 export var WSAEMFILE: number;
6542 export var WSAEWOULDBLOCK: number;
6543 export var WSAEINPROGRESS: number;
6544 export var WSAEALREADY: number;
6545 export var WSAENOTSOCK: number;
6546 export var WSAEDESTADDRREQ: number;
6547 export var WSAEMSGSIZE: number;
6548 export var WSAEPROTOTYPE: number;
6549 export var WSAENOPROTOOPT: number;
6550 export var WSAEPROTONOSUPPORT: number;
6551 export var WSAESOCKTNOSUPPORT: number;
6552 export var WSAEOPNOTSUPP: number;
6553 export var WSAEPFNOSUPPORT: number;
6554 export var WSAEAFNOSUPPORT: number;
6555 export var WSAEADDRINUSE: number;
6556 export var WSAEADDRNOTAVAIL: number;
6557 export var WSAENETDOWN: number;
6558 export var WSAENETUNREACH: number;
6559 export var WSAENETRESET: number;
6560 export var WSAECONNABORTED: number;
6561 export var WSAECONNRESET: number;
6562 export var WSAENOBUFS: number;
6563 export var WSAEISCONN: number;
6564 export var WSAENOTCONN: number;
6565 export var WSAESHUTDOWN: number;
6566 export var WSAETOOMANYREFS: number;
6567 export var WSAETIMEDOUT: number;
6568 export var WSAECONNREFUSED: number;
6569 export var WSAELOOP: number;
6570 export var WSAENAMETOOLONG: number;
6571 export var WSAEHOSTDOWN: number;
6572 export var WSAEHOSTUNREACH: number;
6573 export var WSAENOTEMPTY: number;
6574 export var WSAEPROCLIM: number;
6575 export var WSAEUSERS: number;
6576 export var WSAEDQUOT: number;
6577 export var WSAESTALE: number;
6578 export var WSAEREMOTE: number;
6579 export var WSASYSNOTREADY: number;
6580 export var WSAVERNOTSUPPORTED: number;
6581 export var WSANOTINITIALISED: number;
6582 export var WSAEDISCON: number;
6583 export var WSAENOMORE: number;
6584 export var WSAECANCELLED: number;
6585 export var WSAEINVALIDPROCTABLE: number;
6586 export var WSAEINVALIDPROVIDER: number;
6587 export var WSAEPROVIDERFAILEDINIT: number;
6588 export var WSASYSCALLFAILURE: number;
6589 export var WSASERVICE_NOT_FOUND: number;
6590 export var WSATYPE_NOT_FOUND: number;
6591 export var WSA_E_NO_MORE: number;
6592 export var WSA_E_CANCELLED: number;
6593 export var WSAEREFUSED: number;
6594 export var SIGHUP: number;
6595 export var SIGINT: number;
6596 export var SIGILL: number;
6597 export var SIGABRT: number;
6598 export var SIGFPE: number;
6599 export var SIGKILL: number;
6600 export var SIGSEGV: number;
6601 export var SIGTERM: number;
6602 export var SIGBREAK: number;
6603 export var SIGWINCH: number;
6604 export var SSL_OP_ALL: number;
6605 export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
6606 export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
6607 export var SSL_OP_CISCO_ANYCONNECT: number;
6608 export var SSL_OP_COOKIE_EXCHANGE: number;
6609 export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
6610 export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
6611 export var SSL_OP_EPHEMERAL_RSA: number;
6612 export var SSL_OP_LEGACY_SERVER_CONNECT: number;
6613 export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
6614 export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
6615 export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
6616 export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
6617 export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
6618 export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
6619 export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
6620 export var SSL_OP_NO_COMPRESSION: number;
6621 export var SSL_OP_NO_QUERY_MTU: number;
6622 export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
6623 export var SSL_OP_NO_SSLv2: number;
6624 export var SSL_OP_NO_SSLv3: number;
6625 export var SSL_OP_NO_TICKET: number;
6626 export var SSL_OP_NO_TLSv1: number;
6627 export var SSL_OP_NO_TLSv1_1: number;
6628 export var SSL_OP_NO_TLSv1_2: number;
6629 export var SSL_OP_PKCS1_CHECK_1: number;
6630 export var SSL_OP_PKCS1_CHECK_2: number;
6631 export var SSL_OP_SINGLE_DH_USE: number;
6632 export var SSL_OP_SINGLE_ECDH_USE: number;
6633 export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
6634 export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
6635 export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
6636 export var SSL_OP_TLS_D5_BUG: number;
6637 export var SSL_OP_TLS_ROLLBACK_BUG: number;
6638 export var ENGINE_METHOD_DSA: number;
6639 export var ENGINE_METHOD_DH: number;
6640 export var ENGINE_METHOD_RAND: number;
6641 export var ENGINE_METHOD_ECDH: number;
6642 export var ENGINE_METHOD_ECDSA: number;
6643 export var ENGINE_METHOD_CIPHERS: number;
6644 export var ENGINE_METHOD_DIGESTS: number;
6645 export var ENGINE_METHOD_STORE: number;
6646 export var ENGINE_METHOD_PKEY_METHS: number;
6647 export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
6648 export var ENGINE_METHOD_ALL: number;
6649 export var ENGINE_METHOD_NONE: number;
6650 export var DH_CHECK_P_NOT_SAFE_PRIME: number;
6651 export var DH_CHECK_P_NOT_PRIME: number;
6652 export var DH_UNABLE_TO_CHECK_GENERATOR: number;
6653 export var DH_NOT_SUITABLE_GENERATOR: number;
6654 export var NPN_ENABLED: number;
6655 export var RSA_PKCS1_PADDING: number;
6656 export var RSA_SSLV23_PADDING: number;
6657 export var RSA_NO_PADDING: number;
6658 export var RSA_PKCS1_OAEP_PADDING: number;
6659 export var RSA_X931_PADDING: number;
6660 export var RSA_PKCS1_PSS_PADDING: number;
6661 export var POINT_CONVERSION_COMPRESSED: number;
6662 export var POINT_CONVERSION_UNCOMPRESSED: number;
6663 export var POINT_CONVERSION_HYBRID: number;
6664 export var O_RDONLY: number;
6665 export var O_WRONLY: number;
6666 export var O_RDWR: number;
6667 export var S_IFMT: number;
6668 export var S_IFREG: number;
6669 export var S_IFDIR: number;
6670 export var S_IFCHR: number;
6671 export var S_IFBLK: number;
6672 export var S_IFIFO: number;
6673 export var S_IFSOCK: number;
6674 export var S_IRWXU: number;
6675 export var S_IRUSR: number;
6676 export var S_IWUSR: number;
6677 export var S_IXUSR: number;
6678 export var S_IRWXG: number;
6679 export var S_IRGRP: number;
6680 export var S_IWGRP: number;
6681 export var S_IXGRP: number;
6682 export var S_IRWXO: number;
6683 export var S_IROTH: number;
6684 export var S_IWOTH: number;
6685 export var S_IXOTH: number;
6686 export var S_IFLNK: number;
6687 export var O_CREAT: number;
6688 export var O_EXCL: number;
6689 export var O_NOCTTY: number;
6690 export var O_DIRECTORY: number;
6691 export var O_NOATIME: number;
6692 export var O_NOFOLLOW: number;
6693 export var O_SYNC: number;
6694 export var O_DSYNC: number;
6695 export var O_SYMLINK: number;
6696 export var O_DIRECT: number;
6697 export var O_NONBLOCK: number;
6698 export var O_TRUNC: number;
6699 export var O_APPEND: number;
6700 export var F_OK: number;
6701 export var R_OK: number;
6702 export var W_OK: number;
6703 export var X_OK: number;
6704 export var COPYFILE_EXCL: number;
6705 export var COPYFILE_FICLONE: number;
6706 export var COPYFILE_FICLONE_FORCE: number;
6707 export var UV_UDP_REUSEADDR: number;
6708 export var SIGQUIT: number;
6709 export var SIGTRAP: number;
6710 export var SIGIOT: number;
6711 export var SIGBUS: number;
6712 export var SIGUSR1: number;
6713 export var SIGUSR2: number;
6714 export var SIGPIPE: number;
6715 export var SIGALRM: number;
6716 export var SIGCHLD: number;
6717 export var SIGSTKFLT: number;
6718 export var SIGCONT: number;
6719 export var SIGSTOP: number;
6720 export var SIGTSTP: number;
6721 export var SIGTTIN: number;
6722 export var SIGTTOU: number;
6723 export var SIGURG: number;
6724 export var SIGXCPU: number;
6725 export var SIGXFSZ: number;
6726 export var SIGVTALRM: number;
6727 export var SIGPROF: number;
6728 export var SIGIO: number;
6729 export var SIGPOLL: number;
6730 export var SIGPWR: number;
6731 export var SIGSYS: number;
6732 export var SIGUNUSED: number;
6733 export var defaultCoreCipherList: string;
6734 export var defaultCipherList: string;
6735 export var ENGINE_METHOD_RSA: number;
6736 export var ALPN_ENABLED: number;
6737}
6738
6739declare module "module" {
6740 export = NodeJS.Module;
6741}
6742
6743declare module "process" {
6744 export = process;
6745}
6746
6747declare module "v8" {
6748 interface HeapSpaceInfo {
6749 space_name: string;
6750 space_size: number;
6751 space_used_size: number;
6752 space_available_size: number;
6753 physical_space_size: number;
6754 }
6755
6756 // ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
6757 type DoesZapCodeSpaceFlag = 0 | 1;
6758
6759 interface HeapInfo {
6760 total_heap_size: number;
6761 total_heap_size_executable: number;
6762 total_physical_size: number;
6763 total_available_size: number;
6764 used_heap_size: number;
6765 heap_size_limit: number;
6766 malloced_memory: number;
6767 peak_malloced_memory: number;
6768 does_zap_garbage: DoesZapCodeSpaceFlag;
6769 }
6770
6771 export function getHeapStatistics(): HeapInfo;
6772 export function getHeapSpaceStatistics(): HeapSpaceInfo[];
6773 export function setFlagsFromString(flags: string): void;
6774}
6775
6776declare module "timers" {
6777 export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
6778 export namespace setTimeout {
6779 export function __promisify__(ms: number): Promise<void>;
6780 export function __promisify__<T>(ms: number, value: T): Promise<T>;
6781 }
6782 export function clearTimeout(timeoutId: NodeJS.Timer): void;
6783 export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
6784 export function clearInterval(intervalId: NodeJS.Timer): void;
6785 export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
6786 export namespace setImmediate {
6787 export function __promisify__(): Promise<void>;
6788 export function __promisify__<T>(value: T): Promise<T>;
6789 }
6790 export function clearImmediate(immediateId: any): void;
6791}
6792
6793declare module "console" {
6794 export = console;
6795}
6796
6797/**
6798 * Async Hooks module: https://nodejs.org/api/async_hooks.html
6799 */
6800declare module "async_hooks" {
6801 /**
6802 * Returns the asyncId of the current execution context.
6803 */
6804 export function executionAsyncId(): number;
6805
6806 /**
6807 * Returns the ID of the resource responsible for calling the callback that is currently being executed.
6808 */
6809 export function triggerAsyncId(): number;
6810
6811 export interface HookCallbacks {
6812 /**
6813 * Called when a class is constructed that has the possibility to emit an asynchronous event.
6814 * @param asyncId a unique ID for the async resource
6815 * @param type the type of the async resource
6816 * @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
6817 * @param resource reference to the resource representing the async operation, needs to be released during destroy
6818 */
6819 init?(asyncId: number, type: string, triggerAsyncId: number, resource: Object): void;
6820
6821 /**
6822 * When an asynchronous operation is initiated or completes a callback is called to notify the user.
6823 * The before callback is called just before said callback is executed.
6824 * @param asyncId the unique identifier assigned to the resource about to execute the callback.
6825 */
6826 before?(asyncId: number): void;
6827
6828 /**
6829 * Called immediately after the callback specified in before is completed.
6830 * @param asyncId the unique identifier assigned to the resource which has executed the callback.
6831 */
6832 after?(asyncId: number): void;
6833
6834 /**
6835 * Called when a promise has resolve() called. This may not be in the same execution id
6836 * as the promise itself.
6837 * @param asyncId the unique id for the promise that was resolve()d.
6838 */
6839 promiseResolve?(asyncId: number): void;
6840
6841 /**
6842 * Called after the resource corresponding to asyncId is destroyed
6843 * @param asyncId a unique ID for the async resource
6844 */
6845 destroy?(asyncId: number): void;
6846 }
6847
6848 export interface AsyncHook {
6849 /**
6850 * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
6851 */
6852 enable(): this;
6853
6854 /**
6855 * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
6856 */
6857 disable(): this;
6858 }
6859
6860 /**
6861 * Registers functions to be called for different lifetime events of each async operation.
6862 * @param options the callbacks to register
6863 * @return an AsyncHooks instance used for disabling and enabling hooks
6864 */
6865 export function createHook(options: HookCallbacks): AsyncHook;
6866
6867 export interface AsyncResourceOptions {
6868 /**
6869 * The ID of the execution context that created this async event.
6870 * Default: `executionAsyncId()`
6871 */
6872 triggerAsyncId?: number;
6873
6874 /**
6875 * Disables automatic `emitDestroy` when the object is garbage collected.
6876 * This usually does not need to be set (even if `emitDestroy` is called
6877 * manually), unless the resource's `asyncId` is retrieved and the
6878 * sensitive API's `emitDestroy` is called with it.
6879 * Default: `false`
6880 */
6881 requireManualDestroy?: boolean;
6882 }
6883
6884 /**
6885 * The class AsyncResource was designed to be extended by the embedder's async resources.
6886 * Using this users can easily trigger the lifetime events of their own resources.
6887 */
6888 export class AsyncResource {
6889 /**
6890 * AsyncResource() is meant to be extended. Instantiating a
6891 * new AsyncResource() also triggers init. If triggerAsyncId is omitted then
6892 * async_hook.executionAsyncId() is used.
6893 * @param type The type of async event.
6894 * @param triggerAsyncId The ID of the execution context that created
6895 * this async event (default: `executionAsyncId()`), or an
6896 * AsyncResourceOptions object (since 9.3)
6897 */
6898 constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
6899
6900 /**
6901 * Call AsyncHooks before callbacks.
6902 * @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
6903 */
6904 emitBefore(): void;
6905
6906 /**
6907 * Call AsyncHooks after callbacks.
6908 * @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
6909 */
6910 emitAfter(): void;
6911
6912 /**
6913 * Call the provided function with the provided arguments in the
6914 * execution context of the async resource. This will establish the
6915 * context, trigger the AsyncHooks before callbacks, call the function,
6916 * trigger the AsyncHooks after callbacks, and then restore the original
6917 * execution context.
6918 * @param fn The function to call in the execution context of this
6919 * async resource.
6920 * @param thisArg The receiver to be used for the function call.
6921 * @param args Optional arguments to pass to the function.
6922 */
6923 runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
6924
6925 /**
6926 * Call AsyncHooks destroy callbacks.
6927 */
6928 emitDestroy(): void;
6929
6930 /**
6931 * @return the unique ID assigned to this AsyncResource instance.
6932 */
6933 asyncId(): number;
6934
6935 /**
6936 * @return the trigger ID for this AsyncResource instance.
6937 */
6938 triggerAsyncId(): number;
6939 }
6940}
6941
6942declare module "http2" {
6943 import * as events from "events";
6944 import * as fs from "fs";
6945 import * as net from "net";
6946 import * as stream from "stream";
6947 import * as tls from "tls";
6948 import * as url from "url";
6949
6950 import { IncomingHttpHeaders as Http1IncomingHttpHeaders, OutgoingHttpHeaders } from "http";
6951 export { OutgoingHttpHeaders } from "http";
6952
6953 export interface IncomingHttpStatusHeader {
6954 ":status"?: number;
6955 }
6956
6957 export interface IncomingHttpHeaders extends Http1IncomingHttpHeaders {
6958 ":path"?: string;
6959 ":method"?: string;
6960 ":authority"?: string;
6961 ":scheme"?: string;
6962 }
6963
6964 // Http2Stream
6965
6966 export interface StreamPriorityOptions {
6967 exclusive?: boolean;
6968 parent?: number;
6969 weight?: number;
6970 silent?: boolean;
6971 }
6972
6973 export interface StreamState {
6974 localWindowSize?: number;
6975 state?: number;
6976 streamLocalClose?: number;
6977 streamRemoteClose?: number;
6978 sumDependencyWeight?: number;
6979 weight?: number;
6980 }
6981
6982 export interface ServerStreamResponseOptions {
6983 endStream?: boolean;
6984 getTrailers?: (trailers: OutgoingHttpHeaders) => void;
6985 }
6986
6987 export interface StatOptions {
6988 offset: number;
6989 length: number;
6990 }
6991
6992 export interface ServerStreamFileResponseOptions {
6993 statCheck?: (stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void | boolean;
6994 getTrailers?: (trailers: OutgoingHttpHeaders) => void;
6995 offset?: number;
6996 length?: number;
6997 }
6998
6999 export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
7000 onError?: (err: NodeJS.ErrnoException) => void;
7001 }
7002
7003 export interface Http2Stream extends stream.Duplex {
7004 readonly aborted: boolean;
7005 close(code?: number, callback?: () => void): void;
7006 readonly closed: boolean;
7007 readonly destroyed: boolean;
7008 readonly pending: boolean;
7009 priority(options: StreamPriorityOptions): void;
7010 readonly rstCode: number;
7011 readonly session: Http2Session;
7012 setTimeout(msecs: number, callback?: () => void): void;
7013 readonly state: StreamState;
7014
7015 addListener(event: string, listener: (...args: any[]) => void): this;
7016 addListener(event: "aborted", listener: () => void): this;
7017 addListener(event: "close", listener: () => void): this;
7018 addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
7019 addListener(event: "drain", listener: () => void): this;
7020 addListener(event: "end", listener: () => void): this;
7021 addListener(event: "error", listener: (err: Error) => void): this;
7022 addListener(event: "finish", listener: () => void): this;
7023 addListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
7024 addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
7025 addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
7026 addListener(event: "streamClosed", listener: (code: number) => void): this;
7027 addListener(event: "timeout", listener: () => void): this;
7028 addListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
7029
7030 emit(event: string | symbol, ...args: any[]): boolean;
7031 emit(event: "aborted"): boolean;
7032 emit(event: "close"): boolean;
7033 emit(event: "data", chunk: Buffer | string): boolean;
7034 emit(event: "drain"): boolean;
7035 emit(event: "end"): boolean;
7036 emit(event: "error", err: Error): boolean;
7037 emit(event: "finish"): boolean;
7038 emit(event: "frameError", frameType: number, errorCode: number): boolean;
7039 emit(event: "pipe", src: stream.Readable): boolean;
7040 emit(event: "unpipe", src: stream.Readable): boolean;
7041 emit(event: "streamClosed", code: number): boolean;
7042 emit(event: "timeout"): boolean;
7043 emit(event: "trailers", trailers: IncomingHttpHeaders, flags: number): boolean;
7044
7045 on(event: string, listener: (...args: any[]) => void): this;
7046 on(event: "aborted", listener: () => void): this;
7047 on(event: "close", listener: () => void): this;
7048 on(event: "data", listener: (chunk: Buffer | string) => void): this;
7049 on(event: "drain", listener: () => void): this;
7050 on(event: "end", listener: () => void): this;
7051 on(event: "error", listener: (err: Error) => void): this;
7052 on(event: "finish", listener: () => void): this;
7053 on(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
7054 on(event: "pipe", listener: (src: stream.Readable) => void): this;
7055 on(event: "unpipe", listener: (src: stream.Readable) => void): this;
7056 on(event: "streamClosed", listener: (code: number) => void): this;
7057 on(event: "timeout", listener: () => void): this;
7058 on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
7059
7060 once(event: string, listener: (...args: any[]) => void): this;
7061 once(event: "aborted", listener: () => void): this;
7062 once(event: "close", listener: () => void): this;
7063 once(event: "data", listener: (chunk: Buffer | string) => void): this;
7064 once(event: "drain", listener: () => void): this;
7065 once(event: "end", listener: () => void): this;
7066 once(event: "error", listener: (err: Error) => void): this;
7067 once(event: "finish", listener: () => void): this;
7068 once(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
7069 once(event: "pipe", listener: (src: stream.Readable) => void): this;
7070 once(event: "unpipe", listener: (src: stream.Readable) => void): this;
7071 once(event: "streamClosed", listener: (code: number) => void): this;
7072 once(event: "timeout", listener: () => void): this;
7073 once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
7074
7075 prependListener(event: string, listener: (...args: any[]) => void): this;
7076 prependListener(event: "aborted", listener: () => void): this;
7077 prependListener(event: "close", listener: () => void): this;
7078 prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
7079 prependListener(event: "drain", listener: () => void): this;
7080 prependListener(event: "end", listener: () => void): this;
7081 prependListener(event: "error", listener: (err: Error) => void): this;
7082 prependListener(event: "finish", listener: () => void): this;
7083 prependListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
7084 prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
7085 prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
7086 prependListener(event: "streamClosed", listener: (code: number) => void): this;
7087 prependListener(event: "timeout", listener: () => void): this;
7088 prependListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
7089
7090 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7091 prependOnceListener(event: "aborted", listener: () => void): this;
7092 prependOnceListener(event: "close", listener: () => void): this;
7093 prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
7094 prependOnceListener(event: "drain", listener: () => void): this;
7095 prependOnceListener(event: "end", listener: () => void): this;
7096 prependOnceListener(event: "error", listener: (err: Error) => void): this;
7097 prependOnceListener(event: "finish", listener: () => void): this;
7098 prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number) => void): this;
7099 prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
7100 prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
7101 prependOnceListener(event: "streamClosed", listener: (code: number) => void): this;
7102 prependOnceListener(event: "timeout", listener: () => void): this;
7103 prependOnceListener(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): this;
7104 }
7105
7106 export interface ClientHttp2Stream extends Http2Stream {
7107 addListener(event: string, listener: (...args: any[]) => void): this;
7108 addListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7109 addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
7110 addListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7111
7112 emit(event: string | symbol, ...args: any[]): boolean;
7113 emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
7114 emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean;
7115 emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
7116
7117 on(event: string, listener: (...args: any[]) => void): this;
7118 on(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7119 on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
7120 on(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7121
7122 once(event: string, listener: (...args: any[]) => void): this;
7123 once(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7124 once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
7125 once(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7126
7127 prependListener(event: string, listener: (...args: any[]) => void): this;
7128 prependListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7129 prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
7130 prependListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7131
7132 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7133 prependOnceListener(event: "headers", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7134 prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this;
7135 prependOnceListener(event: "response", listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7136 }
7137
7138 export interface ServerHttp2Stream extends Http2Stream {
7139 additionalHeaders(headers: OutgoingHttpHeaders): void;
7140 readonly headersSent: boolean;
7141 readonly pushAllowed: boolean;
7142 pushStream(headers: OutgoingHttpHeaders, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
7143 pushStream(headers: OutgoingHttpHeaders, options?: StreamPriorityOptions, callback?: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
7144 respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
7145 respondWithFD(fd: number, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptions): void;
7146 respondWithFile(path: string, headers?: OutgoingHttpHeaders, options?: ServerStreamFileResponseOptionsWithError): void;
7147 }
7148
7149 // Http2Session
7150
7151 export interface Settings {
7152 headerTableSize?: number;
7153 enablePush?: boolean;
7154 initialWindowSize?: number;
7155 maxFrameSize?: number;
7156 maxConcurrentStreams?: number;
7157 maxHeaderListSize?: number;
7158 }
7159
7160 export interface ClientSessionRequestOptions {
7161 endStream?: boolean;
7162 exclusive?: boolean;
7163 parent?: number;
7164 weight?: number;
7165 getTrailers?: (trailers: OutgoingHttpHeaders, flags: number) => void;
7166 }
7167
7168 export interface SessionState {
7169 effectiveLocalWindowSize?: number;
7170 effectiveRecvDataLength?: number;
7171 nextStreamID?: number;
7172 localWindowSize?: number;
7173 lastProcStreamID?: number;
7174 remoteWindowSize?: number;
7175 outboundQueueSize?: number;
7176 deflateDynamicTableSize?: number;
7177 inflateDynamicTableSize?: number;
7178 }
7179
7180 export interface Http2Session extends events.EventEmitter {
7181 readonly alpnProtocol?: string;
7182 close(callback?: () => void): void;
7183 readonly closed: boolean;
7184 readonly connecting: boolean;
7185 destroy(error?: Error, code?: number): void;
7186 readonly destroyed: boolean;
7187 readonly encrypted?: boolean;
7188 goaway(code?: number, lastStreamID?: number, opaqueData?: Buffer | DataView | NodeJS.TypedArray): void;
7189 readonly localSettings: Settings;
7190 readonly originSet?: string[];
7191 readonly pendingSettingsAck: boolean;
7192 ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
7193 ping(payload: Buffer | DataView | NodeJS.TypedArray , callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
7194 ref(): void;
7195 readonly remoteSettings: Settings;
7196 rstStream(stream: Http2Stream, code?: number): void;
7197 setTimeout(msecs: number, callback?: () => void): void;
7198 readonly socket: net.Socket | tls.TLSSocket;
7199 readonly state: SessionState;
7200 priority(stream: Http2Stream, options: StreamPriorityOptions): void;
7201 settings(settings: Settings): void;
7202 readonly type: number;
7203 unref(): void;
7204
7205 addListener(event: string, listener: (...args: any[]) => void): this;
7206 addListener(event: "close", listener: () => void): this;
7207 addListener(event: "error", listener: (err: Error) => void): this;
7208 addListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
7209 addListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
7210 addListener(event: "localSettings", listener: (settings: Settings) => void): this;
7211 addListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
7212 addListener(event: "timeout", listener: () => void): this;
7213
7214 emit(event: string | symbol, ...args: any[]): boolean;
7215 emit(event: "close"): boolean;
7216 emit(event: "error", err: Error): boolean;
7217 emit(event: "frameError", frameType: number, errorCode: number, streamID: number): boolean;
7218 emit(event: "goaway", errorCode: number, lastStreamID: number, opaqueData: Buffer): boolean;
7219 emit(event: "localSettings", settings: Settings): boolean;
7220 emit(event: "remoteSettings", settings: Settings): boolean;
7221 emit(event: "timeout"): boolean;
7222
7223 on(event: string, listener: (...args: any[]) => void): this;
7224 on(event: "close", listener: () => void): this;
7225 on(event: "error", listener: (err: Error) => void): this;
7226 on(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
7227 on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
7228 on(event: "localSettings", listener: (settings: Settings) => void): this;
7229 on(event: "remoteSettings", listener: (settings: Settings) => void): this;
7230 on(event: "timeout", listener: () => void): this;
7231
7232 once(event: string, listener: (...args: any[]) => void): this;
7233 once(event: "close", listener: () => void): this;
7234 once(event: "error", listener: (err: Error) => void): this;
7235 once(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
7236 once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
7237 once(event: "localSettings", listener: (settings: Settings) => void): this;
7238 once(event: "remoteSettings", listener: (settings: Settings) => void): this;
7239 once(event: "timeout", listener: () => void): this;
7240
7241 prependListener(event: string, listener: (...args: any[]) => void): this;
7242 prependListener(event: "close", listener: () => void): this;
7243 prependListener(event: "error", listener: (err: Error) => void): this;
7244 prependListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
7245 prependListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
7246 prependListener(event: "localSettings", listener: (settings: Settings) => void): this;
7247 prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
7248 prependListener(event: "timeout", listener: () => void): this;
7249
7250 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7251 prependOnceListener(event: "close", listener: () => void): this;
7252 prependOnceListener(event: "error", listener: (err: Error) => void): this;
7253 prependOnceListener(event: "frameError", listener: (frameType: number, errorCode: number, streamID: number) => void): this;
7254 prependOnceListener(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData: Buffer) => void): this;
7255 prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;
7256 prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
7257 prependOnceListener(event: "timeout", listener: () => void): this;
7258 }
7259
7260 export interface ClientHttp2Session extends Http2Session {
7261 request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
7262
7263 addListener(event: string, listener: (...args: any[]) => void): this;
7264 addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
7265 addListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7266 addListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7267
7268 emit(event: string | symbol, ...args: any[]): boolean;
7269 emit(event: "altsvc", alt: string, origin: string, stream: number): boolean;
7270 emit(event: "connect", session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
7271 emit(event: "stream", stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean;
7272
7273 on(event: string, listener: (...args: any[]) => void): this;
7274 on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
7275 on(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7276 on(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7277
7278 once(event: string, listener: (...args: any[]) => void): this;
7279 once(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
7280 once(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7281 once(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7282
7283 prependListener(event: string, listener: (...args: any[]) => void): this;
7284 prependListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
7285 prependListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7286 prependListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7287
7288 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7289 prependOnceListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
7290 prependOnceListener(event: "connect", listener: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7291 prependOnceListener(event: "stream", listener: (stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void): this;
7292 }
7293
7294 export interface AlternativeServiceOptions {
7295 origin: number | string | url.URL;
7296 }
7297
7298 export interface ServerHttp2Session extends Http2Session {
7299 altsvc(alt: string, originOrStream: number | string | url.URL | AlternativeServiceOptions): void;
7300 readonly server: Http2Server | Http2SecureServer;
7301
7302 addListener(event: string, listener: (...args: any[]) => void): this;
7303 addListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7304 addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7305
7306 emit(event: string | symbol, ...args: any[]): boolean;
7307 emit(event: "connect", session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket): boolean;
7308 emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
7309
7310 on(event: string, listener: (...args: any[]) => void): this;
7311 on(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7312 on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7313
7314 once(event: string, listener: (...args: any[]) => void): this;
7315 once(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7316 once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7317
7318 prependListener(event: string, listener: (...args: any[]) => void): this;
7319 prependListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7320 prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7321
7322 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7323 prependOnceListener(event: "connect", listener: (session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket) => void): this;
7324 prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7325 }
7326
7327 // Http2Server
7328
7329 export interface SessionOptions {
7330 maxDeflateDynamicTableSize?: number;
7331 maxReservedRemoteStreams?: number;
7332 maxSendHeaderBlockLength?: number;
7333 paddingStrategy?: number;
7334 peerMaxConcurrentStreams?: number;
7335 selectPadding?: (frameLen: number, maxFrameLen: number) => number;
7336 settings?: Settings;
7337 }
7338
7339 export type ClientSessionOptions = SessionOptions;
7340 export type ServerSessionOptions = SessionOptions;
7341
7342 export interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions { }
7343 export interface SecureServerSessionOptions extends ServerSessionOptions, tls.TlsOptions { }
7344
7345 export interface ServerOptions extends ServerSessionOptions {
7346 allowHTTP1?: boolean;
7347 }
7348
7349 export interface SecureServerOptions extends SecureServerSessionOptions {
7350 allowHTTP1?: boolean;
7351 }
7352
7353 export interface Http2Server extends net.Server {
7354 addListener(event: string, listener: (...args: any[]) => void): this;
7355 addListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7356 addListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7357 addListener(event: "sessionError", listener: (err: Error) => void): this;
7358 addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7359 addListener(event: "timeout", listener: () => void): this;
7360
7361 emit(event: string | symbol, ...args: any[]): boolean;
7362 emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
7363 emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
7364 emit(event: "sessionError", err: Error): boolean;
7365 emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
7366 emit(event: "timeout"): boolean;
7367
7368 on(event: string, listener: (...args: any[]) => void): this;
7369 on(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7370 on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7371 on(event: "sessionError", listener: (err: Error) => void): this;
7372 on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7373 on(event: "timeout", listener: () => void): this;
7374
7375 once(event: string, listener: (...args: any[]) => void): this;
7376 once(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7377 once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7378 once(event: "sessionError", listener: (err: Error) => void): this;
7379 once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7380 once(event: "timeout", listener: () => void): this;
7381
7382 prependListener(event: string, listener: (...args: any[]) => void): this;
7383 prependListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7384 prependListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7385 prependListener(event: "sessionError", listener: (err: Error) => void): this;
7386 prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7387 prependListener(event: "timeout", listener: () => void): this;
7388
7389 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7390 prependOnceListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7391 prependOnceListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7392 prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
7393 prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7394 prependOnceListener(event: "timeout", listener: () => void): this;
7395 }
7396
7397 export interface Http2SecureServer extends tls.Server {
7398 addListener(event: string, listener: (...args: any[]) => void): this;
7399 addListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7400 addListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7401 addListener(event: "sessionError", listener: (err: Error) => void): this;
7402 addListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7403 addListener(event: "timeout", listener: () => void): this;
7404 addListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
7405
7406 emit(event: string | symbol, ...args: any[]): boolean;
7407 emit(event: "checkContinue", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
7408 emit(event: "request", request: Http2ServerRequest, response: Http2ServerResponse): boolean;
7409 emit(event: "sessionError", err: Error): boolean;
7410 emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean;
7411 emit(event: "timeout"): boolean;
7412 emit(event: "unknownProtocol", socket: tls.TLSSocket): boolean;
7413
7414 on(event: string, listener: (...args: any[]) => void): this;
7415 on(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7416 on(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7417 on(event: "sessionError", listener: (err: Error) => void): this;
7418 on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7419 on(event: "timeout", listener: () => void): this;
7420 on(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
7421
7422 once(event: string, listener: (...args: any[]) => void): this;
7423 once(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7424 once(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7425 once(event: "sessionError", listener: (err: Error) => void): this;
7426 once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7427 once(event: "timeout", listener: () => void): this;
7428 once(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
7429
7430 prependListener(event: string, listener: (...args: any[]) => void): this;
7431 prependListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7432 prependListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7433 prependListener(event: "sessionError", listener: (err: Error) => void): this;
7434 prependListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7435 prependListener(event: "timeout", listener: () => void): this;
7436 prependListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
7437
7438 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7439 prependOnceListener(event: "checkContinue", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7440 prependOnceListener(event: "request", listener: (request: Http2ServerRequest, response: Http2ServerResponse) => void): this;
7441 prependOnceListener(event: "sessionError", listener: (err: Error) => void): this;
7442 prependOnceListener(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): this;
7443 prependOnceListener(event: "timeout", listener: () => void): this;
7444 prependOnceListener(event: "unknownProtocol", listener: (socket: tls.TLSSocket) => void): this;
7445 }
7446
7447 export interface Http2ServerRequest extends stream.Readable {
7448 headers: IncomingHttpHeaders;
7449 httpVersion: string;
7450 method: string;
7451 rawHeaders: string[];
7452 rawTrailers: string[];
7453 setTimeout(msecs: number, callback?: () => void): void;
7454 socket: net.Socket | tls.TLSSocket;
7455 stream: ServerHttp2Stream;
7456 trailers: IncomingHttpHeaders;
7457 url: string;
7458
7459 addListener(event: string, listener: (...args: any[]) => void): this;
7460 addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7461
7462 emit(event: string | symbol, ...args: any[]): boolean;
7463 emit(event: "aborted", hadError: boolean, code: number): boolean;
7464
7465 on(event: string, listener: (...args: any[]) => void): this;
7466 on(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7467
7468 once(event: string, listener: (...args: any[]) => void): this;
7469 once(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7470
7471 prependListener(event: string, listener: (...args: any[]) => void): this;
7472 prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7473
7474 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7475 prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7476 }
7477
7478 export interface Http2ServerResponse extends events.EventEmitter {
7479 addTrailers(trailers: OutgoingHttpHeaders): void;
7480 connection: net.Socket | tls.TLSSocket;
7481 end(callback?: () => void): void;
7482 end(data?: string | Buffer, callback?: () => void): void;
7483 end(data?: string | Buffer, encoding?: string, callback?: () => void): void;
7484 readonly finished: boolean;
7485 getHeader(name: string): string;
7486 getHeaderNames(): string[];
7487 getHeaders(): OutgoingHttpHeaders;
7488 hasHeader(name: string): boolean;
7489 readonly headersSent: boolean;
7490 removeHeader(name: string): void;
7491 sendDate: boolean;
7492 setHeader(name: string, value: number | string | string[]): void;
7493 setTimeout(msecs: number, callback?: () => void): void;
7494 socket: net.Socket | tls.TLSSocket;
7495 statusCode: number;
7496 statusMessage: '';
7497 stream: ServerHttp2Stream;
7498 write(chunk: string | Buffer, callback?: (err: Error) => void): boolean;
7499 write(chunk: string | Buffer, encoding?: string, callback?: (err: Error) => void): boolean;
7500 writeContinue(): void;
7501 writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void;
7502 writeHead(statusCode: number, statusMessage?: string, headers?: OutgoingHttpHeaders): void;
7503 createPushResponse(headers: OutgoingHttpHeaders, callback: (err: Error | null, res: Http2ServerResponse) => void): void;
7504
7505 addListener(event: string, listener: (...args: any[]) => void): this;
7506 addListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7507 addListener(event: "close", listener: () => void): this;
7508 addListener(event: "drain", listener: () => void): this;
7509 addListener(event: "error", listener: (error: Error) => void): this;
7510 addListener(event: "finish", listener: () => void): this;
7511
7512 emit(event: string | symbol, ...args: any[]): boolean;
7513 emit(event: "aborted", hadError: boolean, code: number): boolean;
7514 emit(event: "close"): boolean;
7515 emit(event: "drain"): boolean;
7516 emit(event: "error", error: Error): boolean;
7517 emit(event: "finish"): boolean;
7518
7519 on(event: string, listener: (...args: any[]) => void): this;
7520 on(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7521 on(event: "close", listener: () => void): this;
7522 on(event: "drain", listener: () => void): this;
7523 on(event: "error", listener: (error: Error) => void): this;
7524 on(event: "finish", listener: () => void): this;
7525
7526 once(event: string, listener: (...args: any[]) => void): this;
7527 once(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7528 once(event: "close", listener: () => void): this;
7529 once(event: "drain", listener: () => void): this;
7530 once(event: "error", listener: (error: Error) => void): this;
7531 once(event: "finish", listener: () => void): this;
7532
7533 prependListener(event: string, listener: (...args: any[]) => void): this;
7534 prependListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7535 prependListener(event: "close", listener: () => void): this;
7536 prependListener(event: "drain", listener: () => void): this;
7537 prependListener(event: "error", listener: (error: Error) => void): this;
7538 prependListener(event: "finish", listener: () => void): this;
7539
7540 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
7541 prependOnceListener(event: "aborted", listener: (hadError: boolean, code: number) => void): this;
7542 prependOnceListener(event: "close", listener: () => void): this;
7543 prependOnceListener(event: "drain", listener: () => void): this;
7544 prependOnceListener(event: "error", listener: (error: Error) => void): this;
7545 prependOnceListener(event: "finish", listener: () => void): this;
7546 }
7547
7548 // Public API
7549
7550 export namespace constants {
7551 export const NGHTTP2_SESSION_SERVER: number;
7552 export const NGHTTP2_SESSION_CLIENT: number;
7553 export const NGHTTP2_STREAM_STATE_IDLE: number;
7554 export const NGHTTP2_STREAM_STATE_OPEN: number;
7555 export const NGHTTP2_STREAM_STATE_RESERVED_LOCAL: number;
7556 export const NGHTTP2_STREAM_STATE_RESERVED_REMOTE: number;
7557 export const NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: number;
7558 export const NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: number;
7559 export const NGHTTP2_STREAM_STATE_CLOSED: number;
7560 export const NGHTTP2_NO_ERROR: number;
7561 export const NGHTTP2_PROTOCOL_ERROR: number;
7562 export const NGHTTP2_INTERNAL_ERROR: number;
7563 export const NGHTTP2_FLOW_CONTROL_ERROR: number;
7564 export const NGHTTP2_SETTINGS_TIMEOUT: number;
7565 export const NGHTTP2_STREAM_CLOSED: number;
7566 export const NGHTTP2_FRAME_SIZE_ERROR: number;
7567 export const NGHTTP2_REFUSED_STREAM: number;
7568 export const NGHTTP2_CANCEL: number;
7569 export const NGHTTP2_COMPRESSION_ERROR: number;
7570 export const NGHTTP2_CONNECT_ERROR: number;
7571 export const NGHTTP2_ENHANCE_YOUR_CALM: number;
7572 export const NGHTTP2_INADEQUATE_SECURITY: number;
7573 export const NGHTTP2_HTTP_1_1_REQUIRED: number;
7574 export const NGHTTP2_ERR_FRAME_SIZE_ERROR: number;
7575 export const NGHTTP2_FLAG_NONE: number;
7576 export const NGHTTP2_FLAG_END_STREAM: number;
7577 export const NGHTTP2_FLAG_END_HEADERS: number;
7578 export const NGHTTP2_FLAG_ACK: number;
7579 export const NGHTTP2_FLAG_PADDED: number;
7580 export const NGHTTP2_FLAG_PRIORITY: number;
7581 export const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: number;
7582 export const DEFAULT_SETTINGS_ENABLE_PUSH: number;
7583 export const DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: number;
7584 export const DEFAULT_SETTINGS_MAX_FRAME_SIZE: number;
7585 export const MAX_MAX_FRAME_SIZE: number;
7586 export const MIN_MAX_FRAME_SIZE: number;
7587 export const MAX_INITIAL_WINDOW_SIZE: number;
7588 export const NGHTTP2_DEFAULT_WEIGHT: number;
7589 export const NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: number;
7590 export const NGHTTP2_SETTINGS_ENABLE_PUSH: number;
7591 export const NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: number;
7592 export const NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: number;
7593 export const NGHTTP2_SETTINGS_MAX_FRAME_SIZE: number;
7594 export const NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: number;
7595 export const PADDING_STRATEGY_NONE: number;
7596 export const PADDING_STRATEGY_MAX: number;
7597 export const PADDING_STRATEGY_CALLBACK: number;
7598 export const HTTP2_HEADER_STATUS: string;
7599 export const HTTP2_HEADER_METHOD: string;
7600 export const HTTP2_HEADER_AUTHORITY: string;
7601 export const HTTP2_HEADER_SCHEME: string;
7602 export const HTTP2_HEADER_PATH: string;
7603 export const HTTP2_HEADER_ACCEPT_CHARSET: string;
7604 export const HTTP2_HEADER_ACCEPT_ENCODING: string;
7605 export const HTTP2_HEADER_ACCEPT_LANGUAGE: string;
7606 export const HTTP2_HEADER_ACCEPT_RANGES: string;
7607 export const HTTP2_HEADER_ACCEPT: string;
7608 export const HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: string;
7609 export const HTTP2_HEADER_AGE: string;
7610 export const HTTP2_HEADER_ALLOW: string;
7611 export const HTTP2_HEADER_AUTHORIZATION: string;
7612 export const HTTP2_HEADER_CACHE_CONTROL: string;
7613 export const HTTP2_HEADER_CONNECTION: string;
7614 export const HTTP2_HEADER_CONTENT_DISPOSITION: string;
7615 export const HTTP2_HEADER_CONTENT_ENCODING: string;
7616 export const HTTP2_HEADER_CONTENT_LANGUAGE: string;
7617 export const HTTP2_HEADER_CONTENT_LENGTH: string;
7618 export const HTTP2_HEADER_CONTENT_LOCATION: string;
7619 export const HTTP2_HEADER_CONTENT_MD5: string;
7620 export const HTTP2_HEADER_CONTENT_RANGE: string;
7621 export const HTTP2_HEADER_CONTENT_TYPE: string;
7622 export const HTTP2_HEADER_COOKIE: string;
7623 export const HTTP2_HEADER_DATE: string;
7624 export const HTTP2_HEADER_ETAG: string;
7625 export const HTTP2_HEADER_EXPECT: string;
7626 export const HTTP2_HEADER_EXPIRES: string;
7627 export const HTTP2_HEADER_FROM: string;
7628 export const HTTP2_HEADER_HOST: string;
7629 export const HTTP2_HEADER_IF_MATCH: string;
7630 export const HTTP2_HEADER_IF_MODIFIED_SINCE: string;
7631 export const HTTP2_HEADER_IF_NONE_MATCH: string;
7632 export const HTTP2_HEADER_IF_RANGE: string;
7633 export const HTTP2_HEADER_IF_UNMODIFIED_SINCE: string;
7634 export const HTTP2_HEADER_LAST_MODIFIED: string;
7635 export const HTTP2_HEADER_LINK: string;
7636 export const HTTP2_HEADER_LOCATION: string;
7637 export const HTTP2_HEADER_MAX_FORWARDS: string;
7638 export const HTTP2_HEADER_PREFER: string;
7639 export const HTTP2_HEADER_PROXY_AUTHENTICATE: string;
7640 export const HTTP2_HEADER_PROXY_AUTHORIZATION: string;
7641 export const HTTP2_HEADER_RANGE: string;
7642 export const HTTP2_HEADER_REFERER: string;
7643 export const HTTP2_HEADER_REFRESH: string;
7644 export const HTTP2_HEADER_RETRY_AFTER: string;
7645 export const HTTP2_HEADER_SERVER: string;
7646 export const HTTP2_HEADER_SET_COOKIE: string;
7647 export const HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: string;
7648 export const HTTP2_HEADER_TRANSFER_ENCODING: string;
7649 export const HTTP2_HEADER_TE: string;
7650 export const HTTP2_HEADER_UPGRADE: string;
7651 export const HTTP2_HEADER_USER_AGENT: string;
7652 export const HTTP2_HEADER_VARY: string;
7653 export const HTTP2_HEADER_VIA: string;
7654 export const HTTP2_HEADER_WWW_AUTHENTICATE: string;
7655 export const HTTP2_HEADER_HTTP2_SETTINGS: string;
7656 export const HTTP2_HEADER_KEEP_ALIVE: string;
7657 export const HTTP2_HEADER_PROXY_CONNECTION: string;
7658 export const HTTP2_METHOD_ACL: string;
7659 export const HTTP2_METHOD_BASELINE_CONTROL: string;
7660 export const HTTP2_METHOD_BIND: string;
7661 export const HTTP2_METHOD_CHECKIN: string;
7662 export const HTTP2_METHOD_CHECKOUT: string;
7663 export const HTTP2_METHOD_CONNECT: string;
7664 export const HTTP2_METHOD_COPY: string;
7665 export const HTTP2_METHOD_DELETE: string;
7666 export const HTTP2_METHOD_GET: string;
7667 export const HTTP2_METHOD_HEAD: string;
7668 export const HTTP2_METHOD_LABEL: string;
7669 export const HTTP2_METHOD_LINK: string;
7670 export const HTTP2_METHOD_LOCK: string;
7671 export const HTTP2_METHOD_MERGE: string;
7672 export const HTTP2_METHOD_MKACTIVITY: string;
7673 export const HTTP2_METHOD_MKCALENDAR: string;
7674 export const HTTP2_METHOD_MKCOL: string;
7675 export const HTTP2_METHOD_MKREDIRECTREF: string;
7676 export const HTTP2_METHOD_MKWORKSPACE: string;
7677 export const HTTP2_METHOD_MOVE: string;
7678 export const HTTP2_METHOD_OPTIONS: string;
7679 export const HTTP2_METHOD_ORDERPATCH: string;
7680 export const HTTP2_METHOD_PATCH: string;
7681 export const HTTP2_METHOD_POST: string;
7682 export const HTTP2_METHOD_PRI: string;
7683 export const HTTP2_METHOD_PROPFIND: string;
7684 export const HTTP2_METHOD_PROPPATCH: string;
7685 export const HTTP2_METHOD_PUT: string;
7686 export const HTTP2_METHOD_REBIND: string;
7687 export const HTTP2_METHOD_REPORT: string;
7688 export const HTTP2_METHOD_SEARCH: string;
7689 export const HTTP2_METHOD_TRACE: string;
7690 export const HTTP2_METHOD_UNBIND: string;
7691 export const HTTP2_METHOD_UNCHECKOUT: string;
7692 export const HTTP2_METHOD_UNLINK: string;
7693 export const HTTP2_METHOD_UNLOCK: string;
7694 export const HTTP2_METHOD_UPDATE: string;
7695 export const HTTP2_METHOD_UPDATEREDIRECTREF: string;
7696 export const HTTP2_METHOD_VERSION_CONTROL: string;
7697 export const HTTP_STATUS_CONTINUE: number;
7698 export const HTTP_STATUS_SWITCHING_PROTOCOLS: number;
7699 export const HTTP_STATUS_PROCESSING: number;
7700 export const HTTP_STATUS_OK: number;
7701 export const HTTP_STATUS_CREATED: number;
7702 export const HTTP_STATUS_ACCEPTED: number;
7703 export const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: number;
7704 export const HTTP_STATUS_NO_CONTENT: number;
7705 export const HTTP_STATUS_RESET_CONTENT: number;
7706 export const HTTP_STATUS_PARTIAL_CONTENT: number;
7707 export const HTTP_STATUS_MULTI_STATUS: number;
7708 export const HTTP_STATUS_ALREADY_REPORTED: number;
7709 export const HTTP_STATUS_IM_USED: number;
7710 export const HTTP_STATUS_MULTIPLE_CHOICES: number;
7711 export const HTTP_STATUS_MOVED_PERMANENTLY: number;
7712 export const HTTP_STATUS_FOUND: number;
7713 export const HTTP_STATUS_SEE_OTHER: number;
7714 export const HTTP_STATUS_NOT_MODIFIED: number;
7715 export const HTTP_STATUS_USE_PROXY: number;
7716 export const HTTP_STATUS_TEMPORARY_REDIRECT: number;
7717 export const HTTP_STATUS_PERMANENT_REDIRECT: number;
7718 export const HTTP_STATUS_BAD_REQUEST: number;
7719 export const HTTP_STATUS_UNAUTHORIZED: number;
7720 export const HTTP_STATUS_PAYMENT_REQUIRED: number;
7721 export const HTTP_STATUS_FORBIDDEN: number;
7722 export const HTTP_STATUS_NOT_FOUND: number;
7723 export const HTTP_STATUS_METHOD_NOT_ALLOWED: number;
7724 export const HTTP_STATUS_NOT_ACCEPTABLE: number;
7725 export const HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: number;
7726 export const HTTP_STATUS_REQUEST_TIMEOUT: number;
7727 export const HTTP_STATUS_CONFLICT: number;
7728 export const HTTP_STATUS_GONE: number;
7729 export const HTTP_STATUS_LENGTH_REQUIRED: number;
7730 export const HTTP_STATUS_PRECONDITION_FAILED: number;
7731 export const HTTP_STATUS_PAYLOAD_TOO_LARGE: number;
7732 export const HTTP_STATUS_URI_TOO_LONG: number;
7733 export const HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: number;
7734 export const HTTP_STATUS_RANGE_NOT_SATISFIABLE: number;
7735 export const HTTP_STATUS_EXPECTATION_FAILED: number;
7736 export const HTTP_STATUS_TEAPOT: number;
7737 export const HTTP_STATUS_MISDIRECTED_REQUEST: number;
7738 export const HTTP_STATUS_UNPROCESSABLE_ENTITY: number;
7739 export const HTTP_STATUS_LOCKED: number;
7740 export const HTTP_STATUS_FAILED_DEPENDENCY: number;
7741 export const HTTP_STATUS_UNORDERED_COLLECTION: number;
7742 export const HTTP_STATUS_UPGRADE_REQUIRED: number;
7743 export const HTTP_STATUS_PRECONDITION_REQUIRED: number;
7744 export const HTTP_STATUS_TOO_MANY_REQUESTS: number;
7745 export const HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: number;
7746 export const HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: number;
7747 export const HTTP_STATUS_INTERNAL_SERVER_ERROR: number;
7748 export const HTTP_STATUS_NOT_IMPLEMENTED: number;
7749 export const HTTP_STATUS_BAD_GATEWAY: number;
7750 export const HTTP_STATUS_SERVICE_UNAVAILABLE: number;
7751 export const HTTP_STATUS_GATEWAY_TIMEOUT: number;
7752 export const HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: number;
7753 export const HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: number;
7754 export const HTTP_STATUS_INSUFFICIENT_STORAGE: number;
7755 export const HTTP_STATUS_LOOP_DETECTED: number;
7756 export const HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: number;
7757 export const HTTP_STATUS_NOT_EXTENDED: number;
7758 export const HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: number;
7759 }
7760
7761 export function getDefaultSettings(): Settings;
7762 export function getPackedSettings(settings: Settings): Settings;
7763 export function getUnpackedSettings(buf: Buffer | Uint8Array): Settings;
7764
7765 export function createServer(onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
7766 export function createServer(options: ServerOptions, onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
7767
7768 export function createSecureServer(onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2SecureServer;
7769 export function createSecureServer(options: SecureServerOptions, onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2SecureServer;
7770
7771 export function connect(authority: string | url.URL, listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): ClientHttp2Session;
7772 export function connect(authority: string | url.URL, options?: ClientSessionOptions | SecureClientSessionOptions, listener?: (session: ClientHttp2Session, socket: net.Socket | tls.TLSSocket) => void): ClientHttp2Session;
7773}
7774
7775declare module "perf_hooks" {
7776 import { AsyncResource } from "async_hooks";
7777
7778 export interface PerformanceEntry {
7779 /**
7780 * The total number of milliseconds elapsed for this entry.
7781 * This value will not be meaningful for all Performance Entry types.
7782 */
7783 readonly duration: number;
7784
7785 /**
7786 * The name of the performance entry.
7787 */
7788 readonly name: string;
7789
7790 /**
7791 * The high resolution millisecond timestamp marking the starting time of the Performance Entry.
7792 */
7793 readonly startTime: number;
7794
7795 /**
7796 * The type of the performance entry.
7797 * Currently it may be one of: 'node', 'mark', 'measure', 'gc', or 'function'.
7798 */
7799 readonly entryType: string;
7800
7801 /**
7802 * When performanceEntry.entryType is equal to 'gc', the performance.kind property identifies
7803 * the type of garbage collection operation that occurred.
7804 * The value may be one of perf_hooks.constants.
7805 */
7806 readonly kind?: number;
7807 }
7808
7809 export interface PerformanceNodeTiming extends PerformanceEntry {
7810 /**
7811 * The high resolution millisecond timestamp at which the Node.js process completed bootstrap.
7812 */
7813 readonly bootstrapComplete: number;
7814
7815 /**
7816 * The high resolution millisecond timestamp at which cluster processing ended.
7817 */
7818 readonly clusterSetupEnd: number;
7819
7820 /**
7821 * The high resolution millisecond timestamp at which cluster processing started.
7822 */
7823 readonly clusterSetupStart: number;
7824
7825 /**
7826 * The high resolution millisecond timestamp at which the Node.js event loop exited.
7827 */
7828 readonly loopExit: number;
7829
7830 /**
7831 * The high resolution millisecond timestamp at which the Node.js event loop started.
7832 */
7833 readonly loopStart: number;
7834
7835 /**
7836 * The high resolution millisecond timestamp at which main module load ended.
7837 */
7838 readonly moduleLoadEnd: number;
7839
7840 /**
7841 * The high resolution millisecond timestamp at which main module load started.
7842 */
7843 readonly moduleLoadStart: number;
7844
7845 /**
7846 * The high resolution millisecond timestamp at which the Node.js process was initialized.
7847 */
7848 readonly nodeStart: number;
7849
7850 /**
7851 * The high resolution millisecond timestamp at which preload module load ended.
7852 */
7853 readonly preloadModuleLoadEnd: number;
7854
7855 /**
7856 * The high resolution millisecond timestamp at which preload module load started.
7857 */
7858 readonly preloadModuleLoadStart: number;
7859
7860 /**
7861 * The high resolution millisecond timestamp at which third_party_main processing ended.
7862 */
7863 readonly thirdPartyMainEnd: number;
7864
7865 /**
7866 * The high resolution millisecond timestamp at which third_party_main processing started.
7867 */
7868 readonly thirdPartyMainStart: number;
7869
7870 /**
7871 * The high resolution millisecond timestamp at which the V8 platform was initialized.
7872 */
7873 readonly v8Start: number;
7874 }
7875
7876 export interface Performance {
7877 /**
7878 * If name is not provided, removes all PerformanceFunction objects from the Performance Timeline.
7879 * If name is provided, removes entries with name.
7880 * @param name
7881 */
7882 clearFunctions(name?: string): void;
7883
7884 /**
7885 * If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
7886 * If name is provided, removes only the named mark.
7887 * @param name
7888 */
7889 clearMarks(name?: string): void;
7890
7891 /**
7892 * If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline.
7893 * If name is provided, removes only objects whose performanceEntry.name matches name.
7894 */
7895 clearMeasures(name?: string): void;
7896
7897 /**
7898 * Returns a list of all PerformanceEntry objects in chronological order with respect to performanceEntry.startTime.
7899 * @return list of all PerformanceEntry objects
7900 */
7901 getEntries(): PerformanceEntry[];
7902
7903 /**
7904 * Returns a list of all PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
7905 * whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.
7906 * @param name
7907 * @param type
7908 * @return list of all PerformanceEntry objects
7909 */
7910 getEntriesByName(name: string, type?: string): PerformanceEntry[];
7911
7912 /**
7913 * Returns a list of all PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
7914 * whose performanceEntry.entryType is equal to type.
7915 * @param type
7916 * @return list of all PerformanceEntry objects
7917 */
7918 getEntriesByType(type: string): PerformanceEntry[];
7919
7920 /**
7921 * Creates a new PerformanceMark entry in the Performance Timeline.
7922 * A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
7923 * and whose performanceEntry.duration is always 0.
7924 * Performance marks are used to mark specific significant moments in the Performance Timeline.
7925 * @param name
7926 */
7927 mark(name?: string): void;
7928
7929 /**
7930 * Creates a new PerformanceMeasure entry in the Performance Timeline.
7931 * A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
7932 * and whose performanceEntry.duration measures the number of milliseconds elapsed since startMark and endMark.
7933 *
7934 * The startMark argument may identify any existing PerformanceMark in the the Performance Timeline, or may identify
7935 * any of the timestamp properties provided by the PerformanceNodeTiming class. If the named startMark does not exist,
7936 * then startMark is set to timeOrigin by default.
7937 *
7938 * The endMark argument must identify any existing PerformanceMark in the the Performance Timeline or any of the timestamp
7939 * properties provided by the PerformanceNodeTiming class. If the named endMark does not exist, an error will be thrown.
7940 * @param name
7941 * @param startMark
7942 * @param endMark
7943 */
7944 measure(name: string, startMark: string, endMark: string): void;
7945
7946 /**
7947 * An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
7948 */
7949 readonly nodeTiming: PerformanceNodeTiming;
7950
7951 /**
7952 * @return the current high resolution millisecond timestamp
7953 */
7954 now(): number;
7955
7956 /**
7957 * The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
7958 */
7959 readonly timeOrigin: number;
7960
7961 /**
7962 * Wraps a function within a new function that measures the running time of the wrapped function.
7963 * A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
7964 * @param fn
7965 */
7966 timerify<T extends (...optionalParams: any[]) => any>(fn: T): T;
7967 }
7968
7969 export interface PerformanceObserverEntryList {
7970 /**
7971 * @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime.
7972 */
7973 getEntries(): PerformanceEntry[];
7974
7975 /**
7976 * @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
7977 * whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.
7978 */
7979 getEntriesByName(name: string, type?: string): PerformanceEntry[];
7980
7981 /**
7982 * @return Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
7983 * whose performanceEntry.entryType is equal to type.
7984 */
7985 getEntriesByType(type: string): PerformanceEntry[];
7986 }
7987
7988 export type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
7989
7990 export class PerformanceObserver extends AsyncResource {
7991 constructor(callback: PerformanceObserverCallback);
7992
7993 /**
7994 * Disconnects the PerformanceObserver instance from all notifications.
7995 */
7996 disconnect(): void;
7997
7998 /**
7999 * Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes.
8000 * When options.buffered is false, the callback will be invoked once for every PerformanceEntry instance.
8001 * Property buffered defaults to false.
8002 * @param options
8003 */
8004 observe(options: { entryTypes: string[], buffered?: boolean }): void;
8005 }
8006
8007 export namespace constants {
8008 export const NODE_PERFORMANCE_GC_MAJOR: number;
8009 export const NODE_PERFORMANCE_GC_MINOR: number;
8010 export const NODE_PERFORMANCE_GC_INCREMENTAL: number;
8011 export const NODE_PERFORMANCE_GC_WEAKCB: number;
8012 }
8013
8014 const performance: Performance;
8015}