UNPKG

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