UNPKG

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