UNPKG

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