UNPKG

90.3 kBTypeScriptView Raw
1// Type definitions for Node.js v4.x
2// Project: http://nodejs.org/
3// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
4// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
6/************************************************
7* *
8* Node.js v4.x API *
9* *
10************************************************/
11
12interface Error {
13 stack?: string;
14}
15
16
17// compat for TypeScript 1.5.3
18// if you use with --target es3 or --target es5 and use below definitions,
19// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3.
20interface MapConstructor {}
21interface WeakMapConstructor {}
22interface SetConstructor {}
23interface WeakSetConstructor {}
24
25/************************************************
26* *
27* GLOBAL *
28* *
29************************************************/
30declare var process: NodeJS.Process;
31declare var global: NodeJS.Global;
32
33declare var __filename: string;
34declare var __dirname: string;
35
36declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
37declare function clearTimeout(timeoutId: NodeJS.Timer): void;
38declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
39declare function clearInterval(intervalId: NodeJS.Timer): void;
40declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
41declare function clearImmediate(immediateId: any): void;
42
43interface NodeRequireFunction {
44 (id: string): any;
45}
46
47interface NodeRequire extends NodeRequireFunction {
48 resolve(id:string): string;
49 cache: any;
50 extensions: any;
51 main: any;
52}
53
54declare var require: NodeRequire;
55
56interface NodeModule {
57 exports: any;
58 require: NodeRequireFunction;
59 id: string;
60 filename: string;
61 loaded: boolean;
62 parent: any;
63 children: any[];
64}
65
66declare var module: NodeModule;
67
68// Same as module.exports
69declare var exports: any;
70declare var SlowBuffer: {
71 new (str: string, encoding?: string): Buffer;
72 new (size: number): Buffer;
73 new (size: Uint8Array): Buffer;
74 new (array: any[]): Buffer;
75 prototype: Buffer;
76 isBuffer(obj: any): boolean;
77 byteLength(string: string, encoding?: string): number;
78 concat(list: Buffer[], totalLength?: number): Buffer;
79};
80
81
82// Buffer class
83interface Buffer extends NodeBuffer {}
84
85/**
86 * Raw data is stored in instances of the Buffer class.
87 * 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.
88 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
89 */
90declare var Buffer: {
91 /**
92 * Allocates a new buffer containing the given {str}.
93 *
94 * @param str String to store in buffer.
95 * @param encoding encoding to use, optional. Default is 'utf8'
96 */
97 new (str: string, encoding?: string): Buffer;
98 /**
99 * Allocates a new buffer of {size} octets.
100 *
101 * @param size count of octets to allocate.
102 */
103 new (size: number): Buffer;
104 /**
105 * Allocates a new buffer containing the given {array} of octets.
106 *
107 * @param array The octets to store.
108 */
109 new (array: Uint8Array): Buffer;
110 /**
111 * Allocates a new buffer containing the given {array} of octets.
112 *
113 * @param array The octets to store.
114 */
115 new (array: any[]): Buffer;
116 prototype: Buffer;
117 /**
118 * Returns true if {obj} is a Buffer
119 *
120 * @param obj object to test.
121 */
122 isBuffer(obj: any): obj is Buffer;
123 /**
124 * Returns true if {encoding} is a valid encoding argument.
125 * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
126 *
127 * @param encoding string to test.
128 */
129 isEncoding(encoding: string): boolean;
130 /**
131 * Gives the actual byte length of a string. encoding defaults to 'utf8'.
132 * This is not the same as String.prototype.length since that returns the number of characters in a string.
133 *
134 * @param string string to test.
135 * @param encoding encoding used to evaluate (defaults to 'utf8')
136 */
137 byteLength(string: string, encoding?: string): number;
138 /**
139 * Returns a buffer which is the result of concatenating all the buffers in the list together.
140 *
141 * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
142 * If the list has exactly one item, then the first item of the list is returned.
143 * If the list has more than one item, then a new Buffer is created.
144 *
145 * @param list An array of Buffer objects to concatenate
146 * @param totalLength Total length of the buffers when concatenated.
147 * 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.
148 */
149 concat(list: Buffer[], totalLength?: number): Buffer;
150 /**
151 * The same as buf1.compare(buf2).
152 */
153 compare(buf1: Buffer, buf2: Buffer): number;
154};
155
156/************************************************
157* *
158* GLOBAL INTERFACES *
159* *
160************************************************/
161declare module NodeJS {
162 export interface ErrnoException extends Error {
163 errno?: number;
164 code?: string;
165 path?: string;
166 syscall?: string;
167 stack?: string;
168 }
169
170 export interface EventEmitter {
171 addListener(event: string, listener: Function): EventEmitter;
172 on(event: string, listener: Function): EventEmitter;
173 once(event: string, listener: Function): EventEmitter;
174 removeListener(event: string, listener: Function): EventEmitter;
175 removeAllListeners(event?: string): EventEmitter;
176 setMaxListeners(n: number): EventEmitter;
177 getMaxListeners(): number;
178 listeners(event: string): Function[];
179 emit(event: string, ...args: any[]): boolean;
180 listenerCount(type: string): number;
181 }
182
183 export interface ReadableStream extends EventEmitter {
184 readable: boolean;
185 read(size?: number): string|Buffer;
186 setEncoding(encoding: string): void;
187 pause(): void;
188 resume(): void;
189 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
190 unpipe<T extends WritableStream>(destination?: T): void;
191 unshift(chunk: string): void;
192 unshift(chunk: Buffer): void;
193 wrap(oldStream: ReadableStream): ReadableStream;
194 }
195
196 export interface WritableStream extends EventEmitter {
197 writable: boolean;
198 write(buffer: Buffer|string, cb?: Function): boolean;
199 write(str: string, encoding?: string, cb?: Function): boolean;
200 end(): void;
201 end(buffer: Buffer, cb?: Function): void;
202 end(str: string, cb?: Function): void;
203 end(str: string, encoding?: string, cb?: Function): void;
204 }
205
206 export interface ReadWriteStream extends ReadableStream, WritableStream {}
207
208 export interface Process extends EventEmitter {
209 stdout: WritableStream;
210 stderr: WritableStream;
211 stdin: ReadableStream;
212 argv: string[];
213 execPath: string;
214 abort(): void;
215 chdir(directory: string): void;
216 cwd(): string;
217 env: any;
218 exit(code?: number): void;
219 getgid(): number;
220 setgid(id: number): void;
221 setgid(id: string): void;
222 getuid(): number;
223 setuid(id: number): void;
224 setuid(id: string): void;
225 version: string;
226 versions: {
227 http_parser: string;
228 node: string;
229 v8: string;
230 ares: string;
231 uv: string;
232 zlib: string;
233 openssl: string;
234 };
235 config: {
236 target_defaults: {
237 cflags: any[];
238 default_configuration: string;
239 defines: string[];
240 include_dirs: string[];
241 libraries: string[];
242 };
243 variables: {
244 clang: number;
245 host_arch: string;
246 node_install_npm: boolean;
247 node_install_waf: boolean;
248 node_prefix: string;
249 node_shared_openssl: boolean;
250 node_shared_v8: boolean;
251 node_shared_zlib: boolean;
252 node_use_dtrace: boolean;
253 node_use_etw: boolean;
254 node_use_openssl: boolean;
255 target_arch: string;
256 v8_no_strict_aliasing: number;
257 v8_use_snapshot: boolean;
258 visibility: string;
259 };
260 };
261 kill(pid:number, signal?: string|number): void;
262 pid: number;
263 title: string;
264 arch: string;
265 platform: string;
266 memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; };
267 nextTick(callback: Function): void;
268 umask(mask?: number): number;
269 uptime(): number;
270 hrtime(time?:number[]): number[];
271
272 // Worker
273 send?(message: any, sendHandle?: any): void;
274 }
275
276 export interface Global {
277 Array: typeof Array;
278 ArrayBuffer: typeof ArrayBuffer;
279 Boolean: typeof Boolean;
280 Buffer: typeof Buffer;
281 DataView: typeof DataView;
282 Date: typeof Date;
283 Error: typeof Error;
284 EvalError: typeof EvalError;
285 Float32Array: typeof Float32Array;
286 Float64Array: typeof Float64Array;
287 Function: typeof Function;
288 GLOBAL: Global;
289 Infinity: typeof Infinity;
290 Int16Array: typeof Int16Array;
291 Int32Array: typeof Int32Array;
292 Int8Array: typeof Int8Array;
293 Intl: typeof Intl;
294 JSON: typeof JSON;
295 Map: MapConstructor;
296 Math: typeof Math;
297 NaN: typeof NaN;
298 Number: typeof Number;
299 Object: typeof Object;
300 Promise: Function;
301 RangeError: typeof RangeError;
302 ReferenceError: typeof ReferenceError;
303 RegExp: typeof RegExp;
304 Set: SetConstructor;
305 String: typeof String;
306 Symbol: Function;
307 SyntaxError: typeof SyntaxError;
308 TypeError: typeof TypeError;
309 URIError: typeof URIError;
310 Uint16Array: typeof Uint16Array;
311 Uint32Array: typeof Uint32Array;
312 Uint8Array: typeof Uint8Array;
313 Uint8ClampedArray: Function;
314 WeakMap: WeakMapConstructor;
315 WeakSet: WeakSetConstructor;
316 clearImmediate: (immediateId: any) => void;
317 clearInterval: (intervalId: NodeJS.Timer) => void;
318 clearTimeout: (timeoutId: NodeJS.Timer) => void;
319 console: typeof console;
320 decodeURI: typeof decodeURI;
321 decodeURIComponent: typeof decodeURIComponent;
322 encodeURI: typeof encodeURI;
323 encodeURIComponent: typeof encodeURIComponent;
324 escape: (str: string) => string;
325 eval: typeof eval;
326 global: Global;
327 isFinite: typeof isFinite;
328 isNaN: typeof isNaN;
329 parseFloat: typeof parseFloat;
330 parseInt: typeof parseInt;
331 process: Process;
332 root: Global;
333 setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
334 setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
335 setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
336 undefined: typeof undefined;
337 unescape: (str: string) => string;
338 gc: () => void;
339 v8debug?: any;
340 }
341
342 export interface Timer {
343 ref() : void;
344 unref() : void;
345 }
346}
347
348/**
349 * @deprecated
350 */
351interface NodeBuffer {
352 [index: number]: number;
353 write(string: string, offset?: number, length?: number, encoding?: string): number;
354 toString(encoding?: string, start?: number, end?: number): string;
355 toJSON(): any;
356 length: number;
357 equals(otherBuffer: Buffer): boolean;
358 compare(otherBuffer: Buffer): number;
359 copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
360 slice(start?: number, end?: number): Buffer;
361 writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
362 writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
363 writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
364 writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
365 readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
366 readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
367 readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
368 readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
369 readUInt8(offset: number, noAsset?: boolean): number;
370 readUInt16LE(offset: number, noAssert?: boolean): number;
371 readUInt16BE(offset: number, noAssert?: boolean): number;
372 readUInt32LE(offset: number, noAssert?: boolean): number;
373 readUInt32BE(offset: number, noAssert?: boolean): number;
374 readInt8(offset: number, noAssert?: boolean): number;
375 readInt16LE(offset: number, noAssert?: boolean): number;
376 readInt16BE(offset: number, noAssert?: boolean): number;
377 readInt32LE(offset: number, noAssert?: boolean): number;
378 readInt32BE(offset: number, noAssert?: boolean): number;
379 readFloatLE(offset: number, noAssert?: boolean): number;
380 readFloatBE(offset: number, noAssert?: boolean): number;
381 readDoubleLE(offset: number, noAssert?: boolean): number;
382 readDoubleBE(offset: number, noAssert?: boolean): number;
383 writeUInt8(value: number, offset: number, noAssert?: boolean): number;
384 writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
385 writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
386 writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
387 writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
388 writeInt8(value: number, offset: number, noAssert?: boolean): number;
389 writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
390 writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
391 writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
392 writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
393 writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
394 writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
395 writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
396 writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
397 fill(value: any, offset?: number, end?: number): Buffer;
398}
399
400/************************************************
401* *
402* MODULES *
403* *
404************************************************/
405declare module "buffer" {
406 export var INSPECT_MAX_BYTES: number;
407}
408
409declare module "querystring" {
410 export interface StringifyOptions {
411 encodeURIComponent?: Function;
412 }
413
414 export interface ParseOptions {
415 maxKeys?: number;
416 decodeURIComponent?: Function;
417 }
418
419 export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
420 export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
421 export function parse<T extends {}>(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
422 export function escape(str: string): string;
423 export function unescape(str: string): string;
424}
425
426declare module "events" {
427 export class EventEmitter implements NodeJS.EventEmitter {
428 static EventEmitter: EventEmitter;
429 static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
430 static defaultMaxListeners: number;
431
432 addListener(event: string, listener: Function): EventEmitter;
433 on(event: string, listener: Function): EventEmitter;
434 once(event: string, listener: Function): EventEmitter;
435 removeListener(event: string, listener: Function): EventEmitter;
436 removeAllListeners(event?: string): EventEmitter;
437 setMaxListeners(n: number): EventEmitter;
438 getMaxListeners(): number;
439 listeners(event: string): Function[];
440 emit(event: string, ...args: any[]): boolean;
441 listenerCount(type: string): number;
442 }
443}
444
445declare module "http" {
446 import * as events from "events";
447 import * as net from "net";
448 import * as stream from "stream";
449
450 export interface RequestOptions {
451 protocol?: string;
452 host?: string;
453 hostname?: string;
454 family?: number;
455 port?: number
456 localAddress?: string;
457 socketPath?: string;
458 method?: string;
459 path?: string;
460 headers?: { [key: string]: any };
461 auth?: string;
462 agent?: Agent|boolean;
463 }
464
465 export interface Server extends events.EventEmitter {
466 listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
467 listen(port: number, hostname?: string, callback?: Function): Server;
468 listen(path: string, callback?: Function): Server;
469 listen(handle: any, listeningListener?: Function): Server;
470 close(cb?: any): Server;
471 address(): { port: number; family: string; address: string; };
472 maxHeadersCount: number;
473 }
474 /**
475 * @deprecated Use IncomingMessage
476 */
477 export interface ServerRequest extends IncomingMessage {
478 connection: net.Socket;
479 }
480 export interface ServerResponse extends events.EventEmitter, stream.Writable {
481 // Extended base methods
482 write(buffer: Buffer): boolean;
483 write(buffer: Buffer, cb?: Function): boolean;
484 write(str: string, cb?: Function): boolean;
485 write(str: string, encoding?: string, cb?: Function): boolean;
486 write(str: string, encoding?: string, fd?: string): boolean;
487
488 writeContinue(): void;
489 writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
490 writeHead(statusCode: number, headers?: any): void;
491 statusCode: number;
492 statusMessage: string;
493 headersSent: boolean;
494 setHeader(name: string, value: string): void;
495 sendDate: boolean;
496 getHeader(name: string): string;
497 removeHeader(name: string): void;
498 write(chunk: any, encoding?: string): any;
499 addTrailers(headers: any): void;
500
501 // Extended base methods
502 end(): void;
503 end(buffer: Buffer, cb?: Function): void;
504 end(str: string, cb?: Function): void;
505 end(str: string, encoding?: string, cb?: Function): void;
506 end(data?: any, encoding?: string): void;
507 }
508 export interface ClientRequest extends events.EventEmitter, stream.Writable {
509 // Extended base methods
510 write(buffer: Buffer): boolean;
511 write(buffer: Buffer, cb?: Function): boolean;
512 write(str: string, cb?: Function): boolean;
513 write(str: string, encoding?: string, cb?: Function): boolean;
514 write(str: string, encoding?: string, fd?: string): boolean;
515
516 write(chunk: any, encoding?: string): void;
517 abort(): void;
518 setTimeout(timeout: number, callback?: Function): void;
519 setNoDelay(noDelay?: boolean): void;
520 setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
521
522 // Extended base methods
523 end(): void;
524 end(buffer: Buffer, cb?: Function): void;
525 end(str: string, cb?: Function): void;
526 end(str: string, encoding?: string, cb?: Function): void;
527 end(data?: any, encoding?: string): void;
528 }
529 export interface IncomingMessage extends events.EventEmitter, stream.Readable {
530 httpVersion: string;
531 headers: any;
532 rawHeaders: string[];
533 trailers: any;
534 rawTrailers: any;
535 setTimeout(msecs: number, callback: Function): NodeJS.Timer;
536 /**
537 * Only valid for request obtained from http.Server.
538 */
539 method?: string;
540 /**
541 * Only valid for request obtained from http.Server.
542 */
543 url?: string;
544 /**
545 * Only valid for response obtained from http.ClientRequest.
546 */
547 statusCode?: number;
548 /**
549 * Only valid for response obtained from http.ClientRequest.
550 */
551 statusMessage?: string;
552 socket: net.Socket;
553 }
554 /**
555 * @deprecated Use IncomingMessage
556 */
557 export interface ClientResponse extends IncomingMessage { }
558
559 export interface AgentOptions {
560 /**
561 * Keep sockets around in a pool to be used by other requests in the future. Default = false
562 */
563 keepAlive?: boolean;
564 /**
565 * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
566 * Only relevant if keepAlive is set to true.
567 */
568 keepAliveMsecs?: number;
569 /**
570 * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
571 */
572 maxSockets?: number;
573 /**
574 * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
575 */
576 maxFreeSockets?: number;
577 }
578
579 export class Agent {
580 maxSockets: number;
581 sockets: any;
582 requests: any;
583
584 constructor(opts?: AgentOptions);
585
586 /**
587 * Destroy any sockets that are currently in use by the agent.
588 * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
589 * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
590 * sockets may hang open for quite a long time before the server terminates them.
591 */
592 destroy(): void;
593 }
594
595 export var METHODS: string[];
596
597 export var STATUS_CODES: {
598 [errorCode: number]: string;
599 [errorCode: string]: string;
600 };
601 export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server;
602 export function createClient(port?: number, host?: string): any;
603 export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
604 export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
605 export var globalAgent: Agent;
606}
607
608declare module "cluster" {
609 import * as child from "child_process";
610 import * as events from "events";
611
612 export interface ClusterSettings {
613 exec?: string;
614 args?: string[];
615 silent?: boolean;
616 }
617
618 export class Worker extends events.EventEmitter {
619 id: string;
620 process: child.ChildProcess;
621 suicide: boolean;
622 send(message: any, sendHandle?: any): void;
623 kill(signal?: string): void;
624 destroy(signal?: string): void;
625 disconnect(): void;
626 }
627
628 export var settings: ClusterSettings;
629 export var isMaster: boolean;
630 export var isWorker: boolean;
631 export function setupMaster(settings?: ClusterSettings): void;
632 export function fork(env?: any): Worker;
633 export function disconnect(callback?: Function): void;
634 export var worker: Worker;
635 export var workers: Worker[];
636
637 // Event emitter
638 export function addListener(event: string, listener: Function): void;
639 export function on(event: string, listener: Function): any;
640 export function once(event: string, listener: Function): void;
641 export function removeListener(event: string, listener: Function): void;
642 export function removeAllListeners(event?: string): void;
643 export function setMaxListeners(n: number): void;
644 export function listeners(event: string): Function[];
645 export function emit(event: string, ...args: any[]): boolean;
646}
647
648declare module "zlib" {
649 import * as stream from "stream";
650 export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
651
652 export interface Gzip extends stream.Transform { }
653 export interface Gunzip extends stream.Transform { }
654 export interface Deflate extends stream.Transform { }
655 export interface Inflate extends stream.Transform { }
656 export interface DeflateRaw extends stream.Transform { }
657 export interface InflateRaw extends stream.Transform { }
658 export interface Unzip extends stream.Transform { }
659
660 export function createGzip(options?: ZlibOptions): Gzip;
661 export function createGunzip(options?: ZlibOptions): Gunzip;
662 export function createDeflate(options?: ZlibOptions): Deflate;
663 export function createInflate(options?: ZlibOptions): Inflate;
664 export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
665 export function createInflateRaw(options?: ZlibOptions): InflateRaw;
666 export function createUnzip(options?: ZlibOptions): Unzip;
667
668 export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
669 export function deflateSync(buf: Buffer, options?: ZlibOptions): any;
670 export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
671 export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any;
672 export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
673 export function gzipSync(buf: Buffer, options?: ZlibOptions): any;
674 export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
675 export function gunzipSync(buf: Buffer, options?: ZlibOptions): any;
676 export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
677 export function inflateSync(buf: Buffer, options?: ZlibOptions): any;
678 export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
679 export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any;
680 export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
681 export function unzipSync(buf: Buffer, options?: ZlibOptions): any;
682
683 // Constants
684 export var Z_NO_FLUSH: number;
685 export var Z_PARTIAL_FLUSH: number;
686 export var Z_SYNC_FLUSH: number;
687 export var Z_FULL_FLUSH: number;
688 export var Z_FINISH: number;
689 export var Z_BLOCK: number;
690 export var Z_TREES: number;
691 export var Z_OK: number;
692 export var Z_STREAM_END: number;
693 export var Z_NEED_DICT: number;
694 export var Z_ERRNO: number;
695 export var Z_STREAM_ERROR: number;
696 export var Z_DATA_ERROR: number;
697 export var Z_MEM_ERROR: number;
698 export var Z_BUF_ERROR: number;
699 export var Z_VERSION_ERROR: number;
700 export var Z_NO_COMPRESSION: number;
701 export var Z_BEST_SPEED: number;
702 export var Z_BEST_COMPRESSION: number;
703 export var Z_DEFAULT_COMPRESSION: number;
704 export var Z_FILTERED: number;
705 export var Z_HUFFMAN_ONLY: number;
706 export var Z_RLE: number;
707 export var Z_FIXED: number;
708 export var Z_DEFAULT_STRATEGY: number;
709 export var Z_BINARY: number;
710 export var Z_TEXT: number;
711 export var Z_ASCII: number;
712 export var Z_UNKNOWN: number;
713 export var Z_DEFLATED: number;
714 export var Z_NULL: number;
715}
716
717declare module "os" {
718 export interface CpuInfo {
719 model: string;
720 speed: number;
721 times: {
722 user: number;
723 nice: number;
724 sys: number;
725 idle: number;
726 irq: number;
727 }
728 }
729
730 export interface NetworkInterfaceInfo {
731 address: string;
732 netmask: string;
733 family: string;
734 mac: string;
735 internal: boolean;
736 }
737
738 export function tmpdir(): string;
739 export function homedir(): string;
740 export function endianness(): string;
741 export function hostname(): string;
742 export function type(): string;
743 export function platform(): string;
744 export function arch(): string;
745 export function release(): string;
746 export function uptime(): number;
747 export function loadavg(): number[];
748 export function totalmem(): number;
749 export function freemem(): number;
750 export function cpus(): CpuInfo[];
751 export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]};
752 export var EOL: string;
753}
754
755declare module "https" {
756 import * as tls from "tls";
757 import * as events from "events";
758 import * as http from "http";
759
760 export interface ServerOptions {
761 pfx?: any;
762 key?: any;
763 passphrase?: string;
764 cert?: any;
765 ca?: any;
766 crl?: any;
767 ciphers?: string;
768 honorCipherOrder?: boolean;
769 requestCert?: boolean;
770 rejectUnauthorized?: boolean;
771 NPNProtocols?: any;
772 SNICallback?: (servername: string) => any;
773 }
774
775 export interface RequestOptions extends http.RequestOptions{
776 pfx?: any;
777 key?: any;
778 passphrase?: string;
779 cert?: any;
780 ca?: any;
781 ciphers?: string;
782 rejectUnauthorized?: boolean;
783 secureProtocol?: string;
784 }
785
786 export interface Agent {
787 maxSockets: number;
788 sockets: any;
789 requests: any;
790 }
791 export var Agent: {
792 new (options?: RequestOptions): Agent;
793 };
794 export interface Server extends tls.Server { }
795 export function createServer(options: ServerOptions, requestListener?: Function): Server;
796 export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
797 export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
798 export var globalAgent: Agent;
799}
800
801declare module "punycode" {
802 export function decode(string: string): string;
803 export function encode(string: string): string;
804 export function toUnicode(domain: string): string;
805 export function toASCII(domain: string): string;
806 export var ucs2: ucs2;
807 interface ucs2 {
808 decode(string: string): number[];
809 encode(codePoints: number[]): string;
810 }
811 export var version: any;
812}
813
814declare module "repl" {
815 import * as stream from "stream";
816 import * as events from "events";
817
818 export interface ReplOptions {
819 prompt?: string;
820 input?: NodeJS.ReadableStream;
821 output?: NodeJS.WritableStream;
822 terminal?: boolean;
823 eval?: Function;
824 useColors?: boolean;
825 useGlobal?: boolean;
826 ignoreUndefined?: boolean;
827 writer?: Function;
828 }
829 export function start(options: ReplOptions): events.EventEmitter;
830}
831
832declare module "readline" {
833 import * as events from "events";
834 import * as stream from "stream";
835
836 export interface Key {
837 sequence?: string;
838 name?: string;
839 ctrl?: boolean;
840 meta?: boolean;
841 shift?: boolean;
842 }
843
844 export interface ReadLine extends events.EventEmitter {
845 setPrompt(prompt: string): void;
846 prompt(preserveCursor?: boolean): void;
847 question(query: string, callback: (answer: string) => void): void;
848 pause(): ReadLine;
849 resume(): ReadLine;
850 close(): void;
851 write(data: string|Buffer, key?: Key): void;
852 }
853
854 export interface Completer {
855 (line: string): CompleterResult;
856 (line: string, callback: (err: any, result: CompleterResult) => void): any;
857 }
858
859 export interface CompleterResult {
860 completions: string[];
861 line: string;
862 }
863
864 export interface ReadLineOptions {
865 input: NodeJS.ReadableStream;
866 output?: NodeJS.WritableStream;
867 completer?: Completer;
868 terminal?: boolean;
869 historySize?: number;
870 }
871
872 export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
873 export function createInterface(options: ReadLineOptions): ReadLine;
874
875 export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
876 export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void;
877 export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
878 export function clearScreenDown(stream: NodeJS.WritableStream): void;
879}
880
881declare module "vm" {
882 export interface Context { }
883 export interface Script {
884 runInThisContext(): void;
885 runInNewContext(sandbox?: Context): void;
886 }
887 export function runInThisContext(code: string, filename?: string): void;
888 export function runInNewContext(code: string, sandbox?: Context, filename?: string): void;
889 export function runInContext(code: string, context: Context, filename?: string): void;
890 export function createContext(initSandbox?: Context): Context;
891 export function createScript(code: string, filename?: string): Script;
892}
893
894declare module "child_process" {
895 import * as events from "events";
896 import * as stream from "stream";
897
898 export interface ChildProcess extends events.EventEmitter {
899 stdin: stream.Writable;
900 stdout: stream.Readable;
901 stderr: stream.Readable;
902 pid: number;
903 kill(signal?: string): void;
904 send(message: any, sendHandle?: any): void;
905 disconnect(): void;
906 unref(): void;
907 }
908
909 export function spawn(command: string, args?: string[], options?: {
910 cwd?: string;
911 stdio?: any;
912 custom?: any;
913 env?: any;
914 detached?: boolean;
915 }): ChildProcess;
916 export function exec(command: string, options: {
917 cwd?: string;
918 stdio?: any;
919 customFds?: any;
920 env?: any;
921 encoding?: string;
922 timeout?: number;
923 maxBuffer?: number;
924 killSignal?: string;
925 }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
926 export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
927 export function execFile(file: string,
928 callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
929 export function execFile(file: string, args?: string[],
930 callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
931 export function execFile(file: string, args?: string[], options?: {
932 cwd?: string;
933 stdio?: any;
934 customFds?: any;
935 env?: any;
936 encoding?: string;
937 timeout?: number;
938 maxBuffer?: number;
939 killSignal?: string;
940 }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
941 export function fork(modulePath: string, args?: string[], options?: {
942 cwd?: string;
943 env?: any;
944 execPath?: string;
945 execArgv?: string[];
946 silent?: boolean;
947 uid?: number;
948 gid?: number;
949 }): ChildProcess;
950 export function spawnSync(command: string, args?: string[], options?: {
951 cwd?: string;
952 input?: string | Buffer;
953 stdio?: any;
954 env?: any;
955 uid?: number;
956 gid?: number;
957 timeout?: number;
958 maxBuffer?: number;
959 killSignal?: string;
960 encoding?: string;
961 }): {
962 pid: number;
963 output: string[];
964 stdout: string | Buffer;
965 stderr: string | Buffer;
966 status: number;
967 signal: string;
968 error: Error;
969 };
970 export function execSync(command: string, options?: {
971 cwd?: string;
972 input?: string|Buffer;
973 stdio?: any;
974 env?: any;
975 uid?: number;
976 gid?: number;
977 timeout?: number;
978 maxBuffer?: number;
979 killSignal?: string;
980 encoding?: string;
981 }): string | Buffer;
982 export function execFileSync(command: string, args?: string[], options?: {
983 cwd?: string;
984 input?: string|Buffer;
985 stdio?: any;
986 env?: any;
987 uid?: number;
988 gid?: number;
989 timeout?: number;
990 maxBuffer?: number;
991 killSignal?: string;
992 encoding?: string;
993 }): string | Buffer;
994}
995
996declare module "url" {
997 export interface Url {
998 href?: string;
999 protocol?: string;
1000 auth?: string;
1001 hostname?: string;
1002 port?: string;
1003 host?: string;
1004 pathname?: string;
1005 search?: string;
1006 query?: any; // string | Object
1007 slashes?: boolean;
1008 hash?: string;
1009 path?: string;
1010 }
1011
1012 export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
1013 export function format(url: Url): string;
1014 export function resolve(from: string, to: string): string;
1015}
1016
1017declare module "dns" {
1018 export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string;
1019 export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string;
1020 export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1021 export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1022 export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1023 export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1024 export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1025 export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1026 export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1027 export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1028 export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1029 export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[];
1030}
1031
1032declare module "net" {
1033 import * as stream from "stream";
1034
1035 export interface Socket extends stream.Duplex {
1036 // Extended base methods
1037 write(buffer: Buffer): boolean;
1038 write(buffer: Buffer, cb?: Function): boolean;
1039 write(str: string, cb?: Function): boolean;
1040 write(str: string, encoding?: string, cb?: Function): boolean;
1041 write(str: string, encoding?: string, fd?: string): boolean;
1042
1043 connect(port: number, host?: string, connectionListener?: Function): void;
1044 connect(path: string, connectionListener?: Function): void;
1045 bufferSize: number;
1046 setEncoding(encoding?: string): void;
1047 write(data: any, encoding?: string, callback?: Function): void;
1048 destroy(): void;
1049 pause(): void;
1050 resume(): void;
1051 setTimeout(timeout: number, callback?: Function): void;
1052 setNoDelay(noDelay?: boolean): void;
1053 setKeepAlive(enable?: boolean, initialDelay?: number): void;
1054 address(): { port: number; family: string; address: string; };
1055 unref(): void;
1056 ref(): void;
1057
1058 remoteAddress: string;
1059 remoteFamily: string;
1060 remotePort: number;
1061 localAddress: string;
1062 localPort: number;
1063 bytesRead: number;
1064 bytesWritten: number;
1065
1066 // Extended base methods
1067 end(): void;
1068 end(buffer: Buffer, cb?: Function): void;
1069 end(str: string, cb?: Function): void;
1070 end(str: string, encoding?: string, cb?: Function): void;
1071 end(data?: any, encoding?: string): void;
1072 }
1073
1074 export var Socket: {
1075 new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket;
1076 };
1077
1078 export interface Server extends Socket {
1079 listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server;
1080 listen(path: string, listeningListener?: Function): Server;
1081 listen(handle: any, listeningListener?: Function): Server;
1082 close(callback?: Function): Server;
1083 address(): { port: number; family: string; address: string; };
1084 maxConnections: number;
1085 connections: number;
1086 }
1087 export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
1088 export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
1089 export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1090 export function connect(port: number, host?: string, connectionListener?: Function): Socket;
1091 export function connect(path: string, connectionListener?: Function): Socket;
1092 export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1093 export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
1094 export function createConnection(path: string, connectionListener?: Function): Socket;
1095 export function isIP(input: string): number;
1096 export function isIPv4(input: string): boolean;
1097 export function isIPv6(input: string): boolean;
1098}
1099
1100declare module "dgram" {
1101 import * as events from "events";
1102
1103 interface RemoteInfo {
1104 address: string;
1105 port: number;
1106 size: number;
1107 }
1108
1109 interface AddressInfo {
1110 address: string;
1111 family: string;
1112 port: number;
1113 }
1114
1115 export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1116
1117 interface Socket extends events.EventEmitter {
1118 send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1119 bind(port: number, address?: string, callback?: () => void): void;
1120 close(): void;
1121 address(): AddressInfo;
1122 setBroadcast(flag: boolean): void;
1123 setMulticastTTL(ttl: number): void;
1124 setMulticastLoopback(flag: boolean): void;
1125 addMembership(multicastAddress: string, multicastInterface?: string): void;
1126 dropMembership(multicastAddress: string, multicastInterface?: string): void;
1127 }
1128}
1129
1130declare module "fs" {
1131 import * as stream from "stream";
1132 import * as events from "events";
1133
1134 interface Stats {
1135 isFile(): boolean;
1136 isDirectory(): boolean;
1137 isBlockDevice(): boolean;
1138 isCharacterDevice(): boolean;
1139 isSymbolicLink(): boolean;
1140 isFIFO(): boolean;
1141 isSocket(): boolean;
1142 dev: number;
1143 ino: number;
1144 mode: number;
1145 nlink: number;
1146 uid: number;
1147 gid: number;
1148 rdev: number;
1149 size: number;
1150 blksize: number;
1151 blocks: number;
1152 atime: Date;
1153 mtime: Date;
1154 ctime: Date;
1155 birthtime: Date;
1156 }
1157
1158 interface FSWatcher extends events.EventEmitter {
1159 close(): void;
1160 }
1161
1162 export interface ReadStream extends stream.Readable {
1163 close(): void;
1164 }
1165 export interface WriteStream extends stream.Writable {
1166 close(): void;
1167 bytesWritten: number;
1168 }
1169
1170 /**
1171 * Asynchronous rename.
1172 * @param oldPath
1173 * @param newPath
1174 * @param callback No arguments other than a possible exception are given to the completion callback.
1175 */
1176 export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1177 /**
1178 * Synchronous rename
1179 * @param oldPath
1180 * @param newPath
1181 */
1182 export function renameSync(oldPath: string, newPath: string): void;
1183 export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1184 export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1185 export function truncateSync(path: string, len?: number): void;
1186 export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1187 export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1188 export function ftruncateSync(fd: number, len?: number): void;
1189 export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1190 export function chownSync(path: string, uid: number, gid: number): void;
1191 export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1192 export function fchownSync(fd: number, uid: number, gid: number): void;
1193 export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1194 export function lchownSync(path: string, uid: number, gid: number): void;
1195 export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1196 export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1197 export function chmodSync(path: string, mode: number): void;
1198 export function chmodSync(path: string, mode: string): void;
1199 export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1200 export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1201 export function fchmodSync(fd: number, mode: number): void;
1202 export function fchmodSync(fd: number, mode: string): void;
1203 export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1204 export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1205 export function lchmodSync(path: string, mode: number): void;
1206 export function lchmodSync(path: string, mode: string): void;
1207 export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1208 export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1209 export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1210 export function statSync(path: string): Stats;
1211 export function lstatSync(path: string): Stats;
1212 export function fstatSync(fd: number): Stats;
1213 export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1214 export function linkSync(srcpath: string, dstpath: string): void;
1215 export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1216 export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
1217 export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
1218 export function readlinkSync(path: string): string;
1219 export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
1220 export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void;
1221 export function realpathSync(path: string, cache?: { [path: string]: string }): string;
1222 /*
1223 * Asynchronous unlink - deletes the file specified in {path}
1224 *
1225 * @param path
1226 * @param callback No arguments other than a possible exception are given to the completion callback.
1227 */
1228 export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1229 /*
1230 * Synchronous unlink - deletes the file specified in {path}
1231 *
1232 * @param path
1233 */
1234 export function unlinkSync(path: string): void;
1235 /*
1236 * Asynchronous rmdir - removes the directory specified in {path}
1237 *
1238 * @param path
1239 * @param callback No arguments other than a possible exception are given to the completion callback.
1240 */
1241 export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1242 /*
1243 * Synchronous rmdir - removes the directory specified in {path}
1244 *
1245 * @param path
1246 */
1247 export function rmdirSync(path: string): void;
1248 /*
1249 * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1250 *
1251 * @param path
1252 * @param callback No arguments other than a possible exception are given to the completion callback.
1253 */
1254 export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1255 /*
1256 * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1257 *
1258 * @param path
1259 * @param mode
1260 * @param callback No arguments other than a possible exception are given to the completion callback.
1261 */
1262 export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1263 /*
1264 * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1265 *
1266 * @param path
1267 * @param mode
1268 * @param callback No arguments other than a possible exception are given to the completion callback.
1269 */
1270 export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1271 /*
1272 * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1273 *
1274 * @param path
1275 * @param mode
1276 * @param callback No arguments other than a possible exception are given to the completion callback.
1277 */
1278 export function mkdirSync(path: string, mode?: number): void;
1279 /*
1280 * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1281 *
1282 * @param path
1283 * @param mode
1284 * @param callback No arguments other than a possible exception are given to the completion callback.
1285 */
1286 export function mkdirSync(path: string, mode?: string): void;
1287 export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
1288 export function readdirSync(path: string): string[];
1289 export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1290 export function closeSync(fd: number): void;
1291 export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1292 export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1293 export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1294 export function openSync(path: string, flags: string, mode?: number): number;
1295 export function openSync(path: string, flags: string, mode?: string): number;
1296 export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1297 export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1298 export function utimesSync(path: string, atime: number, mtime: number): void;
1299 export function utimesSync(path: string, atime: Date, mtime: Date): void;
1300 export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1301 export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1302 export function futimesSync(fd: number, atime: number, mtime: number): void;
1303 export function futimesSync(fd: number, atime: Date, mtime: Date): void;
1304 export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1305 export function fsyncSync(fd: number): void;
1306 export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1307 export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1308 export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1309 export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1310 export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1311 export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
1312 export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
1313 export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
1314 /*
1315 * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1316 *
1317 * @param fileName
1318 * @param encoding
1319 * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1320 */
1321 export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1322 /*
1323 * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1324 *
1325 * @param fileName
1326 * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1327 * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1328 */
1329 export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1330 /*
1331 * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1332 *
1333 * @param fileName
1334 * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1335 * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1336 */
1337 export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1338 /*
1339 * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1340 *
1341 * @param fileName
1342 * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1343 */
1344 export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1345 /*
1346 * Synchronous readFile - Synchronously reads the entire contents of a file.
1347 *
1348 * @param fileName
1349 * @param encoding
1350 */
1351 export function readFileSync(filename: string, encoding: string): string;
1352 /*
1353 * Synchronous readFile - Synchronously reads the entire contents of a file.
1354 *
1355 * @param fileName
1356 * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1357 */
1358 export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
1359 /*
1360 * Synchronous readFile - Synchronously reads the entire contents of a file.
1361 *
1362 * @param fileName
1363 * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1364 */
1365 export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
1366 export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1367 export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1368 export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1369 export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1370 export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1371 export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1372 export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1373 export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1374 export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1375 export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1376 export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
1377 export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
1378 export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
1379 export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
1380 export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
1381 export function exists(path: string, callback?: (exists: boolean) => void): void;
1382 export function existsSync(path: string): boolean;
1383 /** Constant for fs.access(). File is visible to the calling process. */
1384 export var F_OK: number;
1385 /** Constant for fs.access(). File can be read by the calling process. */
1386 export var R_OK: number;
1387 /** Constant for fs.access(). File can be written by the calling process. */
1388 export var W_OK: number;
1389 /** Constant for fs.access(). File can be executed by the calling process. */
1390 export var X_OK: number;
1391 /** Tests a user's permissions for the file specified by path. */
1392 export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void;
1393 export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
1394 /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
1395 export function accessSync(path: string, mode ?: number): void;
1396 export function createReadStream(path: string, options?: {
1397 flags?: string;
1398 encoding?: string;
1399 fd?: number;
1400 mode?: number;
1401 autoClose?: boolean;
1402 }): ReadStream;
1403 export function createWriteStream(path: string, options?: {
1404 flags?: string;
1405 encoding?: string;
1406 fd?: number;
1407 mode?: number;
1408 }): WriteStream;
1409}
1410
1411declare module "path" {
1412
1413 /**
1414 * A parsed path object generated by path.parse() or consumed by path.format().
1415 */
1416 export interface ParsedPath {
1417 /**
1418 * The root of the path such as '/' or 'c:\'
1419 */
1420 root: string;
1421 /**
1422 * The full directory path such as '/home/user/dir' or 'c:\path\dir'
1423 */
1424 dir: string;
1425 /**
1426 * The file name including extension (if any) such as 'index.html'
1427 */
1428 base: string;
1429 /**
1430 * The file extension (if any) such as '.html'
1431 */
1432 ext: string;
1433 /**
1434 * The file name without extension (if any) such as 'index'
1435 */
1436 name: string;
1437 }
1438
1439 /**
1440 * Normalize a string path, reducing '..' and '.' parts.
1441 * 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.
1442 *
1443 * @param p string path to normalize.
1444 */
1445 export function normalize(p: string): string;
1446 /**
1447 * Join all arguments together and normalize the resulting path.
1448 * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1449 *
1450 * @param paths string paths to join.
1451 */
1452 export function join(...paths: any[]): string;
1453 /**
1454 * Join all arguments together and normalize the resulting path.
1455 * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1456 *
1457 * @param paths string paths to join.
1458 */
1459 export function join(...paths: string[]): string;
1460 /**
1461 * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
1462 *
1463 * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
1464 *
1465 * 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.
1466 *
1467 * @param pathSegments string paths to join. Non-string arguments are ignored.
1468 */
1469 export function resolve(...pathSegments: any[]): string;
1470 /**
1471 * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
1472 *
1473 * @param path path to test.
1474 */
1475 export function isAbsolute(path: string): boolean;
1476 /**
1477 * Solve the relative path from {from} to {to}.
1478 * 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.
1479 *
1480 * @param from
1481 * @param to
1482 */
1483 export function relative(from: string, to: string): string;
1484 /**
1485 * Return the directory name of a path. Similar to the Unix dirname command.
1486 *
1487 * @param p the path to evaluate.
1488 */
1489 export function dirname(p: string): string;
1490 /**
1491 * Return the last portion of a path. Similar to the Unix basename command.
1492 * Often used to extract the file name from a fully qualified path.
1493 *
1494 * @param p the path to evaluate.
1495 * @param ext optionally, an extension to remove from the result.
1496 */
1497 export function basename(p: string, ext?: string): string;
1498 /**
1499 * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
1500 * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
1501 *
1502 * @param p the path to evaluate.
1503 */
1504 export function extname(p: string): string;
1505 /**
1506 * The platform-specific file separator. '\\' or '/'.
1507 */
1508 export var sep: string;
1509 /**
1510 * The platform-specific file delimiter. ';' or ':'.
1511 */
1512 export var delimiter: string;
1513 /**
1514 * Returns an object from a path string - the opposite of format().
1515 *
1516 * @param pathString path to evaluate.
1517 */
1518 export function parse(pathString: string): ParsedPath;
1519 /**
1520 * Returns a path string from an object - the opposite of parse().
1521 *
1522 * @param pathString path to evaluate.
1523 */
1524 export function format(pathObject: ParsedPath): string;
1525
1526 export module posix {
1527 export function normalize(p: string): string;
1528 export function join(...paths: any[]): string;
1529 export function resolve(...pathSegments: any[]): string;
1530 export function isAbsolute(p: string): boolean;
1531 export function relative(from: string, to: string): string;
1532 export function dirname(p: string): string;
1533 export function basename(p: string, ext?: string): string;
1534 export function extname(p: string): string;
1535 export var sep: string;
1536 export var delimiter: string;
1537 export function parse(p: string): ParsedPath;
1538 export function format(pP: ParsedPath): string;
1539 }
1540
1541 export module win32 {
1542 export function normalize(p: string): string;
1543 export function join(...paths: any[]): string;
1544 export function resolve(...pathSegments: any[]): string;
1545 export function isAbsolute(p: string): boolean;
1546 export function relative(from: string, to: string): string;
1547 export function dirname(p: string): string;
1548 export function basename(p: string, ext?: string): string;
1549 export function extname(p: string): string;
1550 export var sep: string;
1551 export var delimiter: string;
1552 export function parse(p: string): ParsedPath;
1553 export function format(pP: ParsedPath): string;
1554 }
1555}
1556
1557declare module "string_decoder" {
1558 export interface NodeStringDecoder {
1559 write(buffer: Buffer): string;
1560 detectIncompleteChar(buffer: Buffer): number;
1561 }
1562 export var StringDecoder: {
1563 new (encoding: string): NodeStringDecoder;
1564 };
1565}
1566
1567declare module "tls" {
1568 import * as crypto from "crypto";
1569 import * as net from "net";
1570 import * as stream from "stream";
1571
1572 var CLIENT_RENEG_LIMIT: number;
1573 var CLIENT_RENEG_WINDOW: number;
1574
1575 export interface TlsOptions {
1576 host?: string;
1577 port?: number;
1578 pfx?: any; //string or buffer
1579 key?: any; //string or buffer
1580 passphrase?: string;
1581 cert?: any;
1582 ca?: any; //string or buffer
1583 crl?: any; //string or string array
1584 ciphers?: string;
1585 honorCipherOrder?: any;
1586 requestCert?: boolean;
1587 rejectUnauthorized?: boolean;
1588 NPNProtocols?: any; //array or Buffer;
1589 SNICallback?: (servername: string) => any;
1590 }
1591
1592 export interface ConnectionOptions {
1593 host?: string;
1594 port?: number;
1595 socket?: net.Socket;
1596 pfx?: any; //string | Buffer
1597 key?: any; //string | Buffer
1598 passphrase?: string;
1599 cert?: any; //string | Buffer
1600 ca?: any; //Array of string | Buffer
1601 rejectUnauthorized?: boolean;
1602 NPNProtocols?: any; //Array of string | Buffer
1603 servername?: string;
1604 }
1605
1606 export interface Server extends net.Server {
1607 // Extended base methods
1608 listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server;
1609 listen(path: string, listeningListener?: Function): Server;
1610 listen(handle: any, listeningListener?: Function): Server;
1611
1612 listen(port: number, host?: string, callback?: Function): Server;
1613 close(): Server;
1614 address(): { port: number; family: string; address: string; };
1615 addContext(hostName: string, credentials: {
1616 key: string;
1617 cert: string;
1618 ca: string;
1619 }): void;
1620 maxConnections: number;
1621 connections: number;
1622 }
1623
1624 export interface ClearTextStream extends stream.Duplex {
1625 authorized: boolean;
1626 authorizationError: Error;
1627 getPeerCertificate(): any;
1628 getCipher: {
1629 name: string;
1630 version: string;
1631 };
1632 address: {
1633 port: number;
1634 family: string;
1635 address: string;
1636 };
1637 remoteAddress: string;
1638 remotePort: number;
1639 }
1640
1641 export interface SecurePair {
1642 encrypted: any;
1643 cleartext: any;
1644 }
1645
1646 export interface SecureContextOptions {
1647 pfx?: any; //string | buffer
1648 key?: any; //string | buffer
1649 passphrase?: string;
1650 cert?: any; // string | buffer
1651 ca?: any; // string | buffer
1652 crl?: any; // string | string[]
1653 ciphers?: string;
1654 honorCipherOrder?: boolean;
1655 }
1656
1657 export interface SecureContext {
1658 context: any;
1659 }
1660
1661 export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server;
1662 export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream;
1663 export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
1664 export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
1665 export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
1666 export function createSecureContext(details: SecureContextOptions): SecureContext;
1667}
1668
1669declare module "crypto" {
1670 export interface CredentialDetails {
1671 pfx: string;
1672 key: string;
1673 passphrase: string;
1674 cert: string;
1675 ca: any; //string | string array
1676 crl: any; //string | string array
1677 ciphers: string;
1678 }
1679 export interface Credentials { context?: any; }
1680 export function createCredentials(details: CredentialDetails): Credentials;
1681 export function createHash(algorithm: string): Hash;
1682 export function createHmac(algorithm: string, key: string): Hmac;
1683 export function createHmac(algorithm: string, key: Buffer): Hmac;
1684 interface Hash {
1685 update(data: any, input_encoding?: string): Hash;
1686 digest(encoding: 'buffer'): Buffer;
1687 digest(encoding: string): any;
1688 digest(): Buffer;
1689 }
1690 interface Hmac {
1691 update(data: any, input_encoding?: string): Hmac;
1692 digest(encoding: 'buffer'): Buffer;
1693 digest(encoding: string): any;
1694 digest(): Buffer;
1695 }
1696 export function createCipher(algorithm: string, password: any): Cipher;
1697 export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
1698 interface Cipher {
1699 update(data: Buffer): Buffer;
1700 update(data: string, input_encoding?: string, output_encoding?: string): string;
1701 final(): Buffer;
1702 final(output_encoding: string): string;
1703 setAutoPadding(auto_padding: boolean): void;
1704 }
1705 export function createDecipher(algorithm: string, password: any): Decipher;
1706 export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
1707 interface Decipher {
1708 update(data: Buffer): Buffer;
1709 update(data: string, input_encoding?: string, output_encoding?: string): string;
1710 final(): Buffer;
1711 final(output_encoding: string): string;
1712 setAutoPadding(auto_padding: boolean): void;
1713 }
1714 export function createSign(algorithm: string): Signer;
1715 interface Signer extends NodeJS.WritableStream {
1716 update(data: any): void;
1717 sign(private_key: string, output_format: string): string;
1718 }
1719 export function createVerify(algorith: string): Verify;
1720 interface Verify extends NodeJS.WritableStream {
1721 update(data: any): void;
1722 verify(object: string, signature: string, signature_format?: string): boolean;
1723 }
1724 export function createDiffieHellman(prime_length: number): DiffieHellman;
1725 export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman;
1726 interface DiffieHellman {
1727 generateKeys(encoding?: string): string;
1728 computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string;
1729 getPrime(encoding?: string): string;
1730 getGenerator(encoding: string): string;
1731 getPublicKey(encoding?: string): string;
1732 getPrivateKey(encoding?: string): string;
1733 setPublicKey(public_key: string, encoding?: string): void;
1734 setPrivateKey(public_key: string, encoding?: string): void;
1735 }
1736 export function getDiffieHellman(group_name: string): DiffieHellman;
1737 export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
1738 export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
1739 export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
1740 export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer;
1741 export function randomBytes(size: number): Buffer;
1742 export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
1743 export function pseudoRandomBytes(size: number): Buffer;
1744 export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
1745}
1746
1747declare module "stream" {
1748 import * as events from "events";
1749
1750 export class Stream extends events.EventEmitter {
1751 pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
1752 }
1753
1754 export interface ReadableOptions {
1755 highWaterMark?: number;
1756 encoding?: string;
1757 objectMode?: boolean;
1758 }
1759
1760 export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
1761 readable: boolean;
1762 constructor(opts?: ReadableOptions);
1763 _read(size: number): void;
1764 read(size?: number): any;
1765 setEncoding(encoding: string): void;
1766 pause(): void;
1767 resume(): void;
1768 pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
1769 unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
1770 unshift(chunk: any): void;
1771 wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
1772 push(chunk: any, encoding?: string): boolean;
1773 }
1774
1775 export interface WritableOptions {
1776 highWaterMark?: number;
1777 decodeStrings?: boolean;
1778 objectMode?: boolean;
1779 }
1780
1781 export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
1782 writable: boolean;
1783 constructor(opts?: WritableOptions);
1784 _write(chunk: any, encoding: string, callback: Function): void;
1785 write(chunk: any, cb?: Function): boolean;
1786 write(chunk: any, encoding?: string, cb?: Function): boolean;
1787 end(): void;
1788 end(chunk: any, cb?: Function): void;
1789 end(chunk: any, encoding?: string, cb?: Function): void;
1790 }
1791
1792 export interface DuplexOptions extends ReadableOptions, WritableOptions {
1793 allowHalfOpen?: boolean;
1794 }
1795
1796 // Note: Duplex extends both Readable and Writable.
1797 export class Duplex extends Readable implements NodeJS.ReadWriteStream {
1798 writable: boolean;
1799 constructor(opts?: DuplexOptions);
1800 _write(chunk: any, encoding: string, callback: Function): void;
1801 write(chunk: any, cb?: Function): boolean;
1802 write(chunk: any, encoding?: string, cb?: Function): boolean;
1803 end(): void;
1804 end(chunk: any, cb?: Function): void;
1805 end(chunk: any, encoding?: string, cb?: Function): void;
1806 }
1807
1808 export interface TransformOptions extends ReadableOptions, WritableOptions {}
1809
1810 // Note: Transform lacks the _read and _write methods of Readable/Writable.
1811 export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
1812 readable: boolean;
1813 writable: boolean;
1814 constructor(opts?: TransformOptions);
1815 _transform(chunk: any, encoding: string, callback: Function): void;
1816 _flush(callback: Function): void;
1817 read(size?: number): any;
1818 setEncoding(encoding: string): void;
1819 pause(): void;
1820 resume(): void;
1821 pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
1822 unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
1823 unshift(chunk: any): void;
1824 wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
1825 push(chunk: any, encoding?: string): boolean;
1826 write(chunk: any, cb?: Function): boolean;
1827 write(chunk: any, encoding?: string, cb?: Function): boolean;
1828 end(): void;
1829 end(chunk: any, cb?: Function): void;
1830 end(chunk: any, encoding?: string, cb?: Function): void;
1831 }
1832
1833 export class PassThrough extends Transform {}
1834}
1835
1836declare module "util" {
1837 export interface InspectOptions {
1838 showHidden?: boolean;
1839 depth?: number;
1840 colors?: boolean;
1841 customInspect?: boolean;
1842 }
1843
1844 export function format(format: any, ...param: any[]): string;
1845 export function debug(string: string): void;
1846 export function error(...param: any[]): void;
1847 export function puts(...param: any[]): void;
1848 export function print(...param: any[]): void;
1849 export function log(string: string): void;
1850 export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string;
1851 export function inspect(object: any, options: InspectOptions): string;
1852 export function isArray(object: any): boolean;
1853 export function isRegExp(object: any): boolean;
1854 export function isDate(object: any): boolean;
1855 export function isError(object: any): boolean;
1856 export function inherits(constructor: any, superConstructor: any): void;
1857 export function debuglog(key:string): (msg:string,...param: any[])=>void;
1858}
1859
1860declare module "assert" {
1861 function internal (value: any, message?: string): void;
1862 module internal {
1863 export class AssertionError implements Error {
1864 name: string;
1865 message: string;
1866 actual: any;
1867 expected: any;
1868 operator: string;
1869 generatedMessage: boolean;
1870
1871 constructor(options?: {message?: string; actual?: any; expected?: any;
1872 operator?: string; stackStartFunction?: Function});
1873 }
1874
1875 export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
1876 export function ok(value: any, message?: string): void;
1877 export function equal(actual: any, expected: any, message?: string): void;
1878 export function notEqual(actual: any, expected: any, message?: string): void;
1879 export function deepEqual(actual: any, expected: any, message?: string): void;
1880 export function notDeepEqual(acutal: any, expected: any, message?: string): void;
1881 export function strictEqual(actual: any, expected: any, message?: string): void;
1882 export function notStrictEqual(actual: any, expected: any, message?: string): void;
1883 export function deepStrictEqual(actual: any, expected: any, message?: string): void;
1884 export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
1885 export var throws: {
1886 (block: Function, message?: string): void;
1887 (block: Function, error: Function, message?: string): void;
1888 (block: Function, error: RegExp, message?: string): void;
1889 (block: Function, error: (err: any) => boolean, message?: string): void;
1890 };
1891
1892 export var doesNotThrow: {
1893 (block: Function, message?: string): void;
1894 (block: Function, error: Function, message?: string): void;
1895 (block: Function, error: RegExp, message?: string): void;
1896 (block: Function, error: (err: any) => boolean, message?: string): void;
1897 };
1898
1899 export function ifError(value: any): void;
1900 }
1901
1902 export = internal;
1903}
1904
1905declare module "tty" {
1906 import * as net from "net";
1907
1908 export function isatty(fd: number): boolean;
1909 export interface ReadStream extends net.Socket {
1910 isRaw: boolean;
1911 setRawMode(mode: boolean): void;
1912 }
1913 export interface WriteStream extends net.Socket {
1914 columns: number;
1915 rows: number;
1916 }
1917}
1918
1919declare module "domain" {
1920 import * as events from "events";
1921
1922 export class Domain extends events.EventEmitter {
1923 run(fn: Function): void;
1924 add(emitter: events.EventEmitter): void;
1925 remove(emitter: events.EventEmitter): void;
1926 bind(cb: (err: Error, data: any) => any): any;
1927 intercept(cb: (data: any) => any): any;
1928 dispose(): void;
1929
1930 addListener(event: string, listener: Function): Domain;
1931 on(event: string, listener: Function): Domain;
1932 once(event: string, listener: Function): Domain;
1933 removeListener(event: string, listener: Function): Domain;
1934 removeAllListeners(event?: string): Domain;
1935 }
1936
1937 export function create(): Domain;
1938}
1939
1940declare module "constants" {
1941 export var E2BIG: number;
1942 export var EACCES: number;
1943 export var EADDRINUSE: number;
1944 export var EADDRNOTAVAIL: number;
1945 export var EAFNOSUPPORT: number;
1946 export var EAGAIN: number;
1947 export var EALREADY: number;
1948 export var EBADF: number;
1949 export var EBADMSG: number;
1950 export var EBUSY: number;
1951 export var ECANCELED: number;
1952 export var ECHILD: number;
1953 export var ECONNABORTED: number;
1954 export var ECONNREFUSED: number;
1955 export var ECONNRESET: number;
1956 export var EDEADLK: number;
1957 export var EDESTADDRREQ: number;
1958 export var EDOM: number;
1959 export var EEXIST: number;
1960 export var EFAULT: number;
1961 export var EFBIG: number;
1962 export var EHOSTUNREACH: number;
1963 export var EIDRM: number;
1964 export var EILSEQ: number;
1965 export var EINPROGRESS: number;
1966 export var EINTR: number;
1967 export var EINVAL: number;
1968 export var EIO: number;
1969 export var EISCONN: number;
1970 export var EISDIR: number;
1971 export var ELOOP: number;
1972 export var EMFILE: number;
1973 export var EMLINK: number;
1974 export var EMSGSIZE: number;
1975 export var ENAMETOOLONG: number;
1976 export var ENETDOWN: number;
1977 export var ENETRESET: number;
1978 export var ENETUNREACH: number;
1979 export var ENFILE: number;
1980 export var ENOBUFS: number;
1981 export var ENODATA: number;
1982 export var ENODEV: number;
1983 export var ENOENT: number;
1984 export var ENOEXEC: number;
1985 export var ENOLCK: number;
1986 export var ENOLINK: number;
1987 export var ENOMEM: number;
1988 export var ENOMSG: number;
1989 export var ENOPROTOOPT: number;
1990 export var ENOSPC: number;
1991 export var ENOSR: number;
1992 export var ENOSTR: number;
1993 export var ENOSYS: number;
1994 export var ENOTCONN: number;
1995 export var ENOTDIR: number;
1996 export var ENOTEMPTY: number;
1997 export var ENOTSOCK: number;
1998 export var ENOTSUP: number;
1999 export var ENOTTY: number;
2000 export var ENXIO: number;
2001 export var EOPNOTSUPP: number;
2002 export var EOVERFLOW: number;
2003 export var EPERM: number;
2004 export var EPIPE: number;
2005 export var EPROTO: number;
2006 export var EPROTONOSUPPORT: number;
2007 export var EPROTOTYPE: number;
2008 export var ERANGE: number;
2009 export var EROFS: number;
2010 export var ESPIPE: number;
2011 export var ESRCH: number;
2012 export var ETIME: number;
2013 export var ETIMEDOUT: number;
2014 export var ETXTBSY: number;
2015 export var EWOULDBLOCK: number;
2016 export var EXDEV: number;
2017 export var WSAEINTR: number;
2018 export var WSAEBADF: number;
2019 export var WSAEACCES: number;
2020 export var WSAEFAULT: number;
2021 export var WSAEINVAL: number;
2022 export var WSAEMFILE: number;
2023 export var WSAEWOULDBLOCK: number;
2024 export var WSAEINPROGRESS: number;
2025 export var WSAEALREADY: number;
2026 export var WSAENOTSOCK: number;
2027 export var WSAEDESTADDRREQ: number;
2028 export var WSAEMSGSIZE: number;
2029 export var WSAEPROTOTYPE: number;
2030 export var WSAENOPROTOOPT: number;
2031 export var WSAEPROTONOSUPPORT: number;
2032 export var WSAESOCKTNOSUPPORT: number;
2033 export var WSAEOPNOTSUPP: number;
2034 export var WSAEPFNOSUPPORT: number;
2035 export var WSAEAFNOSUPPORT: number;
2036 export var WSAEADDRINUSE: number;
2037 export var WSAEADDRNOTAVAIL: number;
2038 export var WSAENETDOWN: number;
2039 export var WSAENETUNREACH: number;
2040 export var WSAENETRESET: number;
2041 export var WSAECONNABORTED: number;
2042 export var WSAECONNRESET: number;
2043 export var WSAENOBUFS: number;
2044 export var WSAEISCONN: number;
2045 export var WSAENOTCONN: number;
2046 export var WSAESHUTDOWN: number;
2047 export var WSAETOOMANYREFS: number;
2048 export var WSAETIMEDOUT: number;
2049 export var WSAECONNREFUSED: number;
2050 export var WSAELOOP: number;
2051 export var WSAENAMETOOLONG: number;
2052 export var WSAEHOSTDOWN: number;
2053 export var WSAEHOSTUNREACH: number;
2054 export var WSAENOTEMPTY: number;
2055 export var WSAEPROCLIM: number;
2056 export var WSAEUSERS: number;
2057 export var WSAEDQUOT: number;
2058 export var WSAESTALE: number;
2059 export var WSAEREMOTE: number;
2060 export var WSASYSNOTREADY: number;
2061 export var WSAVERNOTSUPPORTED: number;
2062 export var WSANOTINITIALISED: number;
2063 export var WSAEDISCON: number;
2064 export var WSAENOMORE: number;
2065 export var WSAECANCELLED: number;
2066 export var WSAEINVALIDPROCTABLE: number;
2067 export var WSAEINVALIDPROVIDER: number;
2068 export var WSAEPROVIDERFAILEDINIT: number;
2069 export var WSASYSCALLFAILURE: number;
2070 export var WSASERVICE_NOT_FOUND: number;
2071 export var WSATYPE_NOT_FOUND: number;
2072 export var WSA_E_NO_MORE: number;
2073 export var WSA_E_CANCELLED: number;
2074 export var WSAEREFUSED: number;
2075 export var SIGHUP: number;
2076 export var SIGINT: number;
2077 export var SIGILL: number;
2078 export var SIGABRT: number;
2079 export var SIGFPE: number;
2080 export var SIGKILL: number;
2081 export var SIGSEGV: number;
2082 export var SIGTERM: number;
2083 export var SIGBREAK: number;
2084 export var SIGWINCH: number;
2085 export var SSL_OP_ALL: number;
2086 export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
2087 export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
2088 export var SSL_OP_CISCO_ANYCONNECT: number;
2089 export var SSL_OP_COOKIE_EXCHANGE: number;
2090 export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
2091 export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
2092 export var SSL_OP_EPHEMERAL_RSA: number;
2093 export var SSL_OP_LEGACY_SERVER_CONNECT: number;
2094 export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
2095 export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
2096 export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
2097 export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
2098 export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
2099 export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
2100 export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
2101 export var SSL_OP_NO_COMPRESSION: number;
2102 export var SSL_OP_NO_QUERY_MTU: number;
2103 export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
2104 export var SSL_OP_NO_SSLv2: number;
2105 export var SSL_OP_NO_SSLv3: number;
2106 export var SSL_OP_NO_TICKET: number;
2107 export var SSL_OP_NO_TLSv1: number;
2108 export var SSL_OP_NO_TLSv1_1: number;
2109 export var SSL_OP_NO_TLSv1_2: number;
2110 export var SSL_OP_PKCS1_CHECK_1: number;
2111 export var SSL_OP_PKCS1_CHECK_2: number;
2112 export var SSL_OP_SINGLE_DH_USE: number;
2113 export var SSL_OP_SINGLE_ECDH_USE: number;
2114 export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
2115 export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
2116 export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
2117 export var SSL_OP_TLS_D5_BUG: number;
2118 export var SSL_OP_TLS_ROLLBACK_BUG: number;
2119 export var ENGINE_METHOD_DSA: number;
2120 export var ENGINE_METHOD_DH: number;
2121 export var ENGINE_METHOD_RAND: number;
2122 export var ENGINE_METHOD_ECDH: number;
2123 export var ENGINE_METHOD_ECDSA: number;
2124 export var ENGINE_METHOD_CIPHERS: number;
2125 export var ENGINE_METHOD_DIGESTS: number;
2126 export var ENGINE_METHOD_STORE: number;
2127 export var ENGINE_METHOD_PKEY_METHS: number;
2128 export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
2129 export var ENGINE_METHOD_ALL: number;
2130 export var ENGINE_METHOD_NONE: number;
2131 export var DH_CHECK_P_NOT_SAFE_PRIME: number;
2132 export var DH_CHECK_P_NOT_PRIME: number;
2133 export var DH_UNABLE_TO_CHECK_GENERATOR: number;
2134 export var DH_NOT_SUITABLE_GENERATOR: number;
2135 export var NPN_ENABLED: number;
2136 export var RSA_PKCS1_PADDING: number;
2137 export var RSA_SSLV23_PADDING: number;
2138 export var RSA_NO_PADDING: number;
2139 export var RSA_PKCS1_OAEP_PADDING: number;
2140 export var RSA_X931_PADDING: number;
2141 export var RSA_PKCS1_PSS_PADDING: number;
2142 export var POINT_CONVERSION_COMPRESSED: number;
2143 export var POINT_CONVERSION_UNCOMPRESSED: number;
2144 export var POINT_CONVERSION_HYBRID: number;
2145 export var O_RDONLY: number;
2146 export var O_WRONLY: number;
2147 export var O_RDWR: number;
2148 export var S_IFMT: number;
2149 export var S_IFREG: number;
2150 export var S_IFDIR: number;
2151 export var S_IFCHR: number;
2152 export var S_IFLNK: number;
2153 export var O_CREAT: number;
2154 export var O_EXCL: number;
2155 export var O_TRUNC: number;
2156 export var O_APPEND: number;
2157 export var F_OK: number;
2158 export var R_OK: number;
2159 export var W_OK: number;
2160 export var X_OK: number;
2161 export var UV_UDP_REUSEADDR: number;
2162}