UNPKG

55.9 kBTypeScriptView Raw
1// Type definitions for Node.js v0.10.1
2// Project: http://nodejs.org/
3// Definitions: https://github.com/borisyankov/DefinitelyTyped
4
5/************************************************
6* *
7* Node.js v0.10.1 API *
8* *
9************************************************/
10
11/************************************************
12* *
13* GLOBAL *
14* *
15************************************************/
16declare var process: NodeProcess;
17declare var global: any;
18
19declare var __filename: string;
20declare var __dirname: string;
21
22declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeTimer;
23declare function clearTimeout(timeoutId: NodeTimer): void;
24declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeTimer;
25declare function clearInterval(intervalId: NodeTimer): void;
26declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
27declare function clearImmediate(immediateId: any): void;
28
29declare var require: {
30 (id: string): any;
31 resolve(id: string): string;
32 cache: any;
33 extensions: any;
34 main: any;
35}
36
37declare var module: {
38 exports: any;
39 require(id: string): any;
40 id: string;
41 filename: string;
42 loaded: boolean;
43 parent: any;
44 children: any[];
45}
46
47// Same as module.exports
48declare var exports: any;
49declare var SlowBuffer: {
50 new (str: string, encoding?: string): NodeBuffer;
51 new (size: number): NodeBuffer;
52 new (array: any[]): NodeBuffer;
53 prototype: NodeBuffer;
54 isBuffer(obj: any): boolean;
55 byteLength(string: string, encoding?: string): number;
56 concat(list: NodeBuffer[], totalLength?: number): NodeBuffer;
57};
58declare var Buffer: {
59 new (str: string, encoding?: string): NodeBuffer;
60 new (size: number): NodeBuffer;
61 new (array: any[]): NodeBuffer;
62 prototype: NodeBuffer;
63 isBuffer(obj: any): boolean;
64 byteLength(string: string, encoding?: string): number;
65 concat(list: NodeBuffer[], totalLength?: number): NodeBuffer;
66}
67
68/************************************************
69* *
70* INTERFACES *
71* *
72************************************************/
73
74interface ErrnoException extends Error {
75 errno?: any;
76 code?: string;
77 path?: string;
78 syscall?: string;
79}
80
81interface NodeEventEmitter {
82 addListener(event: string, listener: Function): NodeEventEmitter;
83 on(event: string, listener: Function): NodeEventEmitter;
84 once(event: string, listener: Function): NodeEventEmitter;
85 removeListener(event: string, listener: Function): NodeEventEmitter;
86 removeAllListeners(event?: string): NodeEventEmitter;
87 setMaxListeners(n: number): void;
88 listeners(event: string): Function[];
89 emit(event: string, ...args: any[]): boolean;
90}
91
92interface ReadableStream extends NodeEventEmitter {
93 readable: boolean;
94 read(size?: number): any;
95 setEncoding(encoding: string): void;
96 pause(): void;
97 resume(): void;
98 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
99 unpipe<T extends WritableStream>(destination?: T): void;
100 unshift(chunk: string): void;
101 unshift(chunk: NodeBuffer): void;
102 wrap(oldStream: ReadableStream): ReadableStream;
103}
104
105interface WritableStream extends NodeEventEmitter {
106 writable: boolean;
107 write(buffer: NodeBuffer, cb?: Function): boolean;
108 write(str: string, cb?: Function): boolean;
109 write(str: string, encoding?: string, cb?: Function): boolean;
110 end(): void;
111 end(buffer: NodeBuffer, cb?: Function): void;
112 end(str: string, cb?: Function): void;
113 end(str: string, encoding?: string, cb?: Function): void;
114}
115
116interface ReadWriteStream extends ReadableStream, WritableStream { }
117
118interface NodeProcess extends NodeEventEmitter {
119 stdout: WritableStream;
120 stderr: WritableStream;
121 stdin: ReadableStream;
122 argv: string[];
123 execPath: string;
124 abort(): void;
125 chdir(directory: string): void;
126 cwd(): string;
127 env: any;
128 exit(code?: number): void;
129 getgid(): number;
130 setgid(id: number): void;
131 setgid(id: string): void;
132 getuid(): number;
133 setuid(id: number): void;
134 setuid(id: string): void;
135 version: string;
136 versions: { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; openssl: string; };
137 config: {
138 target_defaults: {
139 cflags: any[];
140 default_configuration: string;
141 defines: string[];
142 include_dirs: string[];
143 libraries: string[];
144 };
145 variables: {
146 clang: number;
147 host_arch: string;
148 node_install_npm: boolean;
149 node_install_waf: boolean;
150 node_prefix: string;
151 node_shared_openssl: boolean;
152 node_shared_v8: boolean;
153 node_shared_zlib: boolean;
154 node_use_dtrace: boolean;
155 node_use_etw: boolean;
156 node_use_openssl: boolean;
157 target_arch: string;
158 v8_no_strict_aliasing: number;
159 v8_use_snapshot: boolean;
160 visibility: string;
161 };
162 };
163 kill(pid: number, signal?: string): void;
164 pid: number;
165 title: string;
166 arch: string;
167 platform: string;
168 memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; };
169 nextTick(callback: Function): void;
170 umask(mask?: number): number;
171 uptime(): number;
172 hrtime(time?: number[]): number[];
173
174 // Worker
175 send? (message: any, sendHandle?: any): void;
176}
177
178// Buffer class
179interface NodeBuffer {
180 [index: number]: number;
181 write(string: string, offset?: number, length?: number, encoding?: string): number;
182 toString(encoding?: string, start?: number, end?: number): string;
183 length: number;
184 copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
185 slice(start?: number, end?: number): NodeBuffer;
186 readUInt8(offset: number, noAsset?: boolean): number;
187 readUInt16LE(offset: number, noAssert?: boolean): number;
188 readUInt16BE(offset: number, noAssert?: boolean): number;
189 readUInt32LE(offset: number, noAssert?: boolean): number;
190 readUInt32BE(offset: number, noAssert?: boolean): number;
191 readInt8(offset: number, noAssert?: boolean): number;
192 readInt16LE(offset: number, noAssert?: boolean): number;
193 readInt16BE(offset: number, noAssert?: boolean): number;
194 readInt32LE(offset: number, noAssert?: boolean): number;
195 readInt32BE(offset: number, noAssert?: boolean): number;
196 readFloatLE(offset: number, noAssert?: boolean): number;
197 readFloatBE(offset: number, noAssert?: boolean): number;
198 readDoubleLE(offset: number, noAssert?: boolean): number;
199 readDoubleBE(offset: number, noAssert?: boolean): number;
200 writeUInt8(value: number, offset: number, noAssert?: boolean): void;
201 writeUInt16LE(value: number, offset: number, noAssert?: boolean): void;
202 writeUInt16BE(value: number, offset: number, noAssert?: boolean): void;
203 writeUInt32LE(value: number, offset: number, noAssert?: boolean): void;
204 writeUInt32BE(value: number, offset: number, noAssert?: boolean): void;
205 writeInt8(value: number, offset: number, noAssert?: boolean): void;
206 writeInt16LE(value: number, offset: number, noAssert?: boolean): void;
207 writeInt16BE(value: number, offset: number, noAssert?: boolean): void;
208 writeInt32LE(value: number, offset: number, noAssert?: boolean): void;
209 writeInt32BE(value: number, offset: number, noAssert?: boolean): void;
210 writeFloatLE(value: number, offset: number, noAssert?: boolean): void;
211 writeFloatBE(value: number, offset: number, noAssert?: boolean): void;
212 writeDoubleLE(value: number, offset: number, noAssert?: boolean): void;
213 writeDoubleBE(value: number, offset: number, noAssert?: boolean): void;
214 fill(value: any, offset?: number, end?: number): void;
215}
216
217interface NodeTimer {
218 ref(): void;
219 unref(): void;
220}
221
222/************************************************
223* *
224* MODULES *
225* *
226************************************************/
227declare module "querystring" {
228 export function stringify(obj: any, sep?: string, eq?: string): string;
229 export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
230 export function escape(): any;
231 export function unescape(): any;
232}
233
234declare module "events" {
235 export class EventEmitter implements NodeEventEmitter {
236 static listenerCount(emitter: EventEmitter, event: string): number;
237
238 addListener(event: string, listener: Function): EventEmitter;
239 on(event: string, listener: Function): EventEmitter;
240 once(event: string, listener: Function): EventEmitter;
241 removeListener(event: string, listener: Function): EventEmitter;
242 removeAllListeners(event?: string): EventEmitter;
243 setMaxListeners(n: number): void;
244 listeners(event: string): Function[];
245 emit(event: string, ...args: any[]): boolean;
246 }
247}
248
249declare module "http" {
250 import events = require("events");
251 import net = require("net");
252 import stream = require("stream");
253
254 export interface Server extends NodeEventEmitter {
255 listen(port: number, hostname?: string, backlog?: number, callback?: Function): void;
256 listen(path: string, callback?: Function): void;
257 listen(handle: any, listeningListener?: Function): void;
258 close(cb?: any): void;
259 maxHeadersCount: number;
260 }
261 export interface ServerRequest extends NodeEventEmitter, ReadableStream {
262 method: string;
263 url: string;
264 headers: any;
265 trailers: string;
266 httpVersion: string;
267 setEncoding(encoding?: string): void;
268 pause(): void;
269 resume(): void;
270 connection: net.NodeSocket;
271 }
272 export interface ServerResponse extends NodeEventEmitter, WritableStream {
273 // Extended base methods
274 write(buffer: NodeBuffer): boolean;
275 write(buffer: NodeBuffer, cb?: Function): boolean;
276 write(str: string, cb?: Function): boolean;
277 write(str: string, encoding?: string, cb?: Function): boolean;
278 write(str: string, encoding?: string, fd?: string): boolean;
279
280 writeContinue(): void;
281 writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
282 writeHead(statusCode: number, headers?: any): void;
283 statusCode: number;
284 setHeader(name: string, value: string): void;
285 sendDate: boolean;
286 getHeader(name: string): string;
287 removeHeader(name: string): void;
288 write(chunk: any, encoding?: string): any;
289 addTrailers(headers: any): void;
290
291 // Extended base methods
292 end(): void;
293 end(buffer: NodeBuffer, cb?: Function): void;
294 end(str: string, cb?: Function): void;
295 end(str: string, encoding?: string, cb?: Function): void;
296 end(data?: any, encoding?: string): void;
297 }
298 export interface ClientRequest extends NodeEventEmitter, WritableStream {
299 // Extended base methods
300 write(buffer: NodeBuffer): boolean;
301 write(buffer: NodeBuffer, cb?: Function): boolean;
302 write(str: string, cb?: Function): boolean;
303 write(str: string, encoding?: string, cb?: Function): boolean;
304 write(str: string, encoding?: string, fd?: string): boolean;
305
306 write(chunk: any, encoding?: string): void;
307 abort(): void;
308 setTimeout(timeout: number, callback?: Function): void;
309 setNoDelay(noDelay?: Function): void;
310 setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
311
312 // Extended base methods
313 end(): void;
314 end(buffer: NodeBuffer, cb?: Function): void;
315 end(str: string, cb?: Function): void;
316 end(str: string, encoding?: string, cb?: Function): void;
317 end(data?: any, encoding?: string): void;
318 }
319 export interface ClientResponse extends NodeEventEmitter, ReadableStream {
320 statusCode: number;
321 httpVersion: string;
322 headers: any;
323 trailers: any;
324 setEncoding(encoding?: string): void;
325 pause(): void;
326 resume(): void;
327 }
328 export interface Agent { maxSockets: number; sockets: any; requests: any; }
329
330 export var STATUS_CODES: any;
331 export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) => void): Server;
332 export function createClient(port?: number, host?: string): any;
333 export function request(options: any, callback?: Function): ClientRequest;
334 export function get(options: any, callback?: Function): ClientRequest;
335 export var globalAgent: Agent;
336}
337
338declare module "cluster" {
339 import child = require("child_process");
340 import events = require("events");
341
342 export interface ClusterSettings {
343 exec?: string;
344 args?: string[];
345 silent?: boolean;
346 }
347
348 export class Worker extends events.EventEmitter {
349 id: string;
350 process: child.ChildProcess;
351 suicide: boolean;
352 send(message: any, sendHandle?: any): void;
353 kill(signal?: string): void;
354 destroy(signal?: string): void;
355 disconnect(): void;
356 }
357
358 export var settings: ClusterSettings;
359 export var isMaster: boolean;
360 export var isWorker: boolean;
361 export function setupMaster(settings?: ClusterSettings): void;
362 export function fork(env?: any): Worker;
363 export function disconnect(callback?: Function): void;
364 export var worker: Worker;
365 export var workers: Worker[];
366
367 // Event emitter
368 export function addListener(event: string, listener: Function): void;
369 export function on(event: string, listener: Function): any;
370 export function once(event: string, listener: Function): void;
371 export function removeListener(event: string, listener: Function): void;
372 export function removeAllListeners(event?: string): void;
373 export function setMaxListeners(n: number): void;
374 export function listeners(event: string): Function[];
375 export function emit(event: string, ...args: any[]): boolean;
376}
377
378declare module "zlib" {
379 import stream = require("stream");
380 export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
381
382 export interface Gzip extends ReadWriteStream { }
383 export interface Gunzip extends ReadWriteStream { }
384 export interface Deflate extends ReadWriteStream { }
385 export interface Inflate extends ReadWriteStream { }
386 export interface DeflateRaw extends ReadWriteStream { }
387 export interface InflateRaw extends ReadWriteStream { }
388 export interface Unzip extends ReadWriteStream { }
389
390 export function createGzip(options?: ZlibOptions): Gzip;
391 export function createGunzip(options?: ZlibOptions): Gunzip;
392 export function createDeflate(options?: ZlibOptions): Deflate;
393 export function createInflate(options?: ZlibOptions): Inflate;
394 export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
395 export function createInflateRaw(options?: ZlibOptions): InflateRaw;
396 export function createUnzip(options?: ZlibOptions): Unzip;
397
398 export function deflate(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
399 export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
400 export function gzip(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
401 export function gunzip(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
402 export function inflate(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
403 export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
404 export function unzip(buf: NodeBuffer, callback: (error: Error, result: any) => void): void;
405
406 // Constants
407 export var Z_NO_FLUSH: number;
408 export var Z_PARTIAL_FLUSH: number;
409 export var Z_SYNC_FLUSH: number;
410 export var Z_FULL_FLUSH: number;
411 export var Z_FINISH: number;
412 export var Z_BLOCK: number;
413 export var Z_TREES: number;
414 export var Z_OK: number;
415 export var Z_STREAM_END: number;
416 export var Z_NEED_DICT: number;
417 export var Z_ERRNO: number;
418 export var Z_STREAM_ERROR: number;
419 export var Z_DATA_ERROR: number;
420 export var Z_MEM_ERROR: number;
421 export var Z_BUF_ERROR: number;
422 export var Z_VERSION_ERROR: number;
423 export var Z_NO_COMPRESSION: number;
424 export var Z_BEST_SPEED: number;
425 export var Z_BEST_COMPRESSION: number;
426 export var Z_DEFAULT_COMPRESSION: number;
427 export var Z_FILTERED: number;
428 export var Z_HUFFMAN_ONLY: number;
429 export var Z_RLE: number;
430 export var Z_FIXED: number;
431 export var Z_DEFAULT_STRATEGY: number;
432 export var Z_BINARY: number;
433 export var Z_TEXT: number;
434 export var Z_ASCII: number;
435 export var Z_UNKNOWN: number;
436 export var Z_DEFLATED: number;
437 export var Z_NULL: number;
438}
439
440declare module "os" {
441 export function tmpDir(): string;
442 export function hostname(): string;
443 export function type(): string;
444 export function platform(): string;
445 export function arch(): string;
446 export function release(): string;
447 export function uptime(): number;
448 export function loadavg(): number[];
449 export function totalmem(): number;
450 export function freemem(): number;
451 export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[];
452 export function networkInterfaces(): any;
453 export var EOL: string;
454}
455
456declare module "https" {
457 import tls = require("tls");
458 import events = require("events");
459 import http = require("http");
460
461 export interface ServerOptions {
462 pfx?: any;
463 key?: any;
464 passphrase?: string;
465 cert?: any;
466 ca?: any;
467 crl?: any;
468 ciphers?: string;
469 honorCipherOrder?: boolean;
470 requestCert?: boolean;
471 rejectUnauthorized?: boolean;
472 NPNProtocols?: any;
473 SNICallback?: (servername: string) => any;
474 }
475
476 export interface RequestOptions {
477 host?: string;
478 hostname?: string;
479 port?: number;
480 path?: string;
481 method?: string;
482 headers?: any;
483 auth?: string;
484 agent?: any;
485 pfx?: any;
486 key?: any;
487 passphrase?: string;
488 cert?: any;
489 ca?: any;
490 ciphers?: string;
491 rejectUnauthorized?: boolean;
492 }
493
494 export interface NodeAgent {
495 maxSockets: number;
496 sockets: any;
497 requests: any;
498 }
499 export var Agent: {
500 new (options?: RequestOptions): NodeAgent;
501 };
502 export interface Server extends tls.Server { }
503 export function createServer(options: ServerOptions, requestListener?: Function): Server;
504 export function request(options: RequestOptions, callback?: (res: NodeEventEmitter) => void): http.ClientRequest;
505 export function get(options: RequestOptions, callback?: (res: NodeEventEmitter) => void): http.ClientRequest;
506 export var globalAgent: NodeAgent;
507}
508
509declare module "punycode" {
510 export function decode(string: string): string;
511 export function encode(string: string): string;
512 export function toUnicode(domain: string): string;
513 export function toASCII(domain: string): string;
514 export var ucs2: ucs2;
515 interface ucs2 {
516 decode(string: string): string;
517 encode(codePoints: number[]): string;
518 }
519 export var version: any;
520}
521
522declare module "repl" {
523 import stream = require("stream");
524 import events = require("events");
525
526 export interface ReplOptions {
527 prompt?: string;
528 input?: ReadableStream;
529 output?: WritableStream;
530 terminal?: boolean;
531 eval?: Function;
532 useColors?: boolean;
533 useGlobal?: boolean;
534 ignoreUndefined?: boolean;
535 writer?: Function;
536 }
537 export function start(options: ReplOptions): NodeEventEmitter;
538}
539
540declare module "readline" {
541 import events = require("events");
542 import stream = require("stream");
543
544 export interface ReadLine extends NodeEventEmitter {
545 setPrompt(prompt: string, length: number): void;
546 prompt(preserveCursor?: boolean): void;
547 question(query: string, callback: Function): void;
548 pause(): void;
549 resume(): void;
550 close(): void;
551 write(data: any, key?: any): void;
552 }
553 export interface ReadLineOptions {
554 input: ReadableStream;
555 output: WritableStream;
556 completer?: Function;
557 terminal?: boolean;
558 }
559 export function createInterface(options: ReadLineOptions): ReadLine;
560}
561
562declare module "vm" {
563 export interface Context { }
564 export interface Script {
565 runInThisContext(): void;
566 runInNewContext(sandbox?: Context): void;
567 }
568 export function runInThisContext(code: string, filename?: string): void;
569 export function runInNewContext(code: string, sandbox?: Context, filename?: string): void;
570 export function runInContext(code: string, context: Context, filename?: string): void;
571 export function createContext(initSandbox?: Context): Context;
572 export function createScript(code: string, filename?: string): Script;
573}
574
575declare module "child_process" {
576 import events = require("events");
577 import stream = require("stream");
578
579 export interface ChildProcess extends NodeEventEmitter {
580 stdin: WritableStream;
581 stdout: ReadableStream;
582 stderr: ReadableStream;
583 pid: number;
584 kill(signal?: string): void;
585 send(message: any, sendHandle: any): void;
586 disconnect(): void;
587 }
588
589 export function spawn(command: string, args?: string[], options?: {
590 cwd?: string;
591 stdio?: any;
592 custom?: any;
593 env?: any;
594 detached?: boolean;
595 }): ChildProcess;
596 export function exec(command: string, options: {
597 cwd?: string;
598 stdio?: any;
599 customFds?: any;
600 env?: any;
601 encoding?: string;
602 timeout?: number;
603 maxBuffer?: number;
604 killSignal?: string;
605 }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => void): ChildProcess;
606 export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => void): ChildProcess;
607 export function execFile(file: string, args: string[], options: {
608 cwd?: string;
609 stdio?: any;
610 customFds?: any;
611 env?: any;
612 encoding?: string;
613 timeout?: number;
614 maxBuffer?: string;
615 killSignal?: string;
616 }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) => void): ChildProcess;
617 export function fork(modulePath: string, args?: string[], options?: {
618 cwd?: string;
619 env?: any;
620 encoding?: string;
621 }): ChildProcess;
622}
623
624declare module "url" {
625 export interface Url {
626 href: string;
627 protocol: string;
628 auth: string;
629 hostname: string;
630 port: string;
631 host: string;
632 pathname: string;
633 search: string;
634 query: string;
635 slashes: boolean;
636 }
637
638 export interface UrlOptions {
639 protocol?: string;
640 auth?: string;
641 hostname?: string;
642 port?: string;
643 host?: string;
644 pathname?: string;
645 search?: string;
646 query?: any;
647 }
648
649 export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url;
650 export function format(url: UrlOptions): string;
651 export function resolve(from: string, to: string): string;
652}
653
654declare module "dns" {
655 export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string;
656 export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string;
657 export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[];
658 export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
659 export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
660 export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
661 export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
662 export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
663 export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
664 export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
665 export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[];
666 export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[];
667}
668
669declare module "net" {
670 import stream = require("stream");
671
672 export interface NodeSocket extends ReadWriteStream {
673 // Extended base methods
674 write(buffer: NodeBuffer): boolean;
675 write(buffer: NodeBuffer, cb?: Function): boolean;
676 write(str: string, cb?: Function): boolean;
677 write(str: string, encoding?: string, cb?: Function): boolean;
678 write(str: string, encoding?: string, fd?: string): boolean;
679
680 connect(port: number, host?: string, connectionListener?: Function): void;
681 connect(path: string, connectionListener?: Function): void;
682 bufferSize: number;
683 setEncoding(encoding?: string): void;
684 write(data: any, encoding?: string, callback?: Function): void;
685 destroy(): void;
686 pause(): void;
687 resume(): void;
688 setTimeout(timeout: number, callback?: Function): void;
689 setNoDelay(noDelay?: boolean): void;
690 setKeepAlive(enable?: boolean, initialDelay?: number): void;
691 address(): { port: number; family: string; address: string; };
692 remoteAddress: string;
693 remotePort: number;
694 bytesRead: number;
695 bytesWritten: number;
696
697 // Extended base methods
698 end(): void;
699 end(buffer: NodeBuffer, cb?: Function): void;
700 end(str: string, cb?: Function): void;
701 end(str: string, encoding?: string, cb?: Function): void;
702 end(data?: any, encoding?: string): void;
703 }
704
705 export var Socket: {
706 new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): NodeSocket;
707 };
708
709 export interface Server extends NodeSocket {
710 listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void;
711 listen(path: string, listeningListener?: Function): void;
712 listen(handle: any, listeningListener?: Function): void;
713 close(callback?: Function): void;
714 address(): { port: number; family: string; address: string; };
715 maxConnections: number;
716 connections: number;
717 }
718 export function createServer(connectionListener?: (socket: NodeSocket) => void): Server;
719 export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: NodeSocket) => void): Server;
720 export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): NodeSocket;
721 export function connect(port: number, host?: string, connectionListener?: Function): NodeSocket;
722 export function connect(path: string, connectionListener?: Function): NodeSocket;
723 export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): NodeSocket;
724 export function createConnection(port: number, host?: string, connectionListener?: Function): NodeSocket;
725 export function createConnection(path: string, connectionListener?: Function): NodeSocket;
726 export function isIP(input: string): number;
727 export function isIPv4(input: string): boolean;
728 export function isIPv6(input: string): boolean;
729}
730
731declare module "dgram" {
732 import events = require("events");
733
734 export function createSocket(type: string, callback?: Function): Socket;
735
736 interface Socket extends NodeEventEmitter {
737 send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void;
738 bind(port: number, address?: string): void;
739 close(): void;
740 address: { address: string; family: string; port: number; };
741 setBroadcast(flag: boolean): void;
742 setMulticastTTL(ttl: number): void;
743 setMulticastLoopback(flag: boolean): void;
744 addMembership(multicastAddress: string, multicastInterface?: string): void;
745 dropMembership(multicastAddress: string, multicastInterface?: string): void;
746 }
747}
748
749declare module "fs" {
750 import stream = require("stream");
751
752 interface Stats {
753 isFile(): boolean;
754 isDirectory(): boolean;
755 isBlockDevice(): boolean;
756 isCharacterDevice(): boolean;
757 isSymbolicLink(): boolean;
758 isFIFO(): boolean;
759 isSocket(): boolean;
760 dev: number;
761 ino: number;
762 mode: number;
763 nlink: number;
764 uid: number;
765 gid: number;
766 rdev: number;
767 size: number;
768 blksize: number;
769 blocks: number;
770 atime: Date;
771 mtime: Date;
772 ctime: Date;
773 }
774
775 interface FSWatcher extends NodeEventEmitter {
776 close(): void;
777 }
778
779 export interface ReadStream extends ReadableStream { }
780 export interface WriteStream extends WritableStream { }
781
782 export function rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void;
783 export function renameSync(oldPath: string, newPath: string): void;
784 export function truncate(path: string, callback?: (err?: ErrnoException) => void): void;
785 export function truncate(path: string, len: number, callback?: (err?: ErrnoException) => void): void;
786 export function truncateSync(path: string, len?: number): void;
787 export function ftruncate(fd: number, callback?: (err?: ErrnoException) => void): void;
788 export function ftruncate(fd: number, len: number, callback?: (err?: ErrnoException) => void): void;
789 export function ftruncateSync(fd: number, len?: number): void;
790 export function chown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void;
791 export function chownSync(path: string, uid: number, gid: number): void;
792 export function fchown(fd: number, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void;
793 export function fchownSync(fd: number, uid: number, gid: number): void;
794 export function lchown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void;
795 export function lchownSync(path: string, uid: number, gid: number): void;
796 export function chmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void;
797 export function chmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void;
798 export function chmodSync(path: string, mode: number): void;
799 export function chmodSync(path: string, mode: string): void;
800 export function fchmod(fd: number, mode: number, callback?: (err?: ErrnoException) => void): void;
801 export function fchmod(fd: number, mode: string, callback?: (err?: ErrnoException) => void): void;
802 export function fchmodSync(fd: number, mode: number): void;
803 export function fchmodSync(fd: number, mode: string): void;
804 export function lchmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void;
805 export function lchmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void;
806 export function lchmodSync(path: string, mode: number): void;
807 export function lchmodSync(path: string, mode: string): void;
808 export function stat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void;
809 export function lstat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void;
810 export function fstat(fd: number, callback?: (err: ErrnoException, stats: Stats) => any): void;
811 export function statSync(path: string): Stats;
812 export function lstatSync(path: string): Stats;
813 export function fstatSync(fd: number): Stats;
814 export function link(srcpath: string, dstpath: string, callback?: (err?: ErrnoException) => void): void;
815 export function linkSync(srcpath: string, dstpath: string): void;
816 export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: ErrnoException) => void): void;
817 export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
818 export function readlink(path: string, callback?: (err: ErrnoException, linkString: string) => any): void;
819 export function readlinkSync(path: string): string;
820 export function realpath(path: string, callback?: (err: ErrnoException, resolvedPath: string) => any): void;
821 export function realpath(path: string, cache: { [path: string]: string }, callback: (err: ErrnoException, resolvedPath: string) => any): void;
822 export function realpathSync(path: string, cache?: { [path: string]: string }): void;
823 export function unlink(path: string, callback?: (err?: ErrnoException) => void): void;
824 export function unlinkSync(path: string): void;
825 export function rmdir(path: string, callback?: (err?: ErrnoException) => void): void;
826 export function rmdirSync(path: string): void;
827 export function mkdir(path: string, callback?: (err?: ErrnoException) => void): void;
828 export function mkdir(path: string, mode: number, callback?: (err?: ErrnoException) => void): void;
829 export function mkdir(path: string, mode: string, callback?: (err?: ErrnoException) => void): void;
830 export function mkdirSync(path: string, mode?: number): void;
831 export function mkdirSync(path: string, mode?: string): void;
832 export function readdir(path: string, callback?: (err: ErrnoException, files: string[]) => void): void;
833 export function readdirSync(path: string): string[];
834 export function close(fd: number, callback?: (err?: ErrnoException) => void): void;
835 export function closeSync(fd: number): void;
836 export function open(path: string, flags: string, callback?: (err: ErrnoException, fd: number) => any): void;
837 export function open(path: string, flags: string, mode: number, callback?: (err: ErrnoException, fd: number) => any): void;
838 export function open(path: string, flags: string, mode: string, callback?: (err: ErrnoException, fd: number) => any): void;
839 export function openSync(path: string, flags: string, mode?: number): number;
840 export function openSync(path: string, flags: string, mode?: string): number;
841 export function utimes(path: string, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void;
842 export function utimesSync(path: string, atime: number, mtime: number): void;
843 export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void;
844 export function futimesSync(fd: number, atime: number, mtime: number): void;
845 export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void;
846 export function fsyncSync(fd: number): void;
847 export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: NodeBuffer) => void): void;
848 export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number;
849 export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: NodeBuffer) => void): void;
850 export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number;
851 export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err: ErrnoException, data: any) => void): void;
852 export function readFile(filename: string, callback: (err: ErrnoException, data: NodeBuffer) => void): void;
853 export function readFileSync(filename: string, options?: { flag?: string; }): NodeBuffer;
854 export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
855 export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void;
856 export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void;
857 export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void;
858 export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
859 export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
860 export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void;
861 export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void;
862 export function appendFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void;
863 export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
864 export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
865 export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
866 export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
867 export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
868 export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
869 export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
870 export function exists(path: string, callback?: (exists: boolean) => void): void;
871 export function existsSync(path: string): boolean;
872 export function createReadStream(path: string, options?: {
873 flags?: string;
874 encoding?: string;
875 fd?: string;
876 mode?: number;
877 bufferSize?: number;
878 }): ReadStream;
879 export function createReadStream(path: string, options?: {
880 flags?: string;
881 encoding?: string;
882 fd?: string;
883 mode?: string;
884 bufferSize?: number;
885 }): ReadStream;
886 export function createWriteStream(path: string, options?: {
887 flags?: string;
888 encoding?: string;
889 string?: string;
890 }): WriteStream;
891}
892
893declare module "path" {
894 export function normalize(p: string): string;
895 export function join(...paths: any[]): string;
896 export function resolve(...pathSegments: any[]): string;
897 export function relative(from: string, to: string): string;
898 export function dirname(p: string): string;
899 export function basename(p: string, ext?: string): string;
900 export function extname(p: string): string;
901 export var sep: string;
902}
903
904declare module "string_decoder" {
905 export interface NodeStringDecoder {
906 write(buffer: NodeBuffer): string;
907 detectIncompleteChar(buffer: NodeBuffer): number;
908 }
909 export var StringDecoder: {
910 new (encoding: string): NodeStringDecoder;
911 };
912}
913
914declare module "tls" {
915 import crypto = require("crypto");
916 import net = require("net");
917 import stream = require("stream");
918
919 var CLIENT_RENEG_LIMIT: number;
920 var CLIENT_RENEG_WINDOW: number;
921
922 export interface TlsOptions {
923 pfx?: any; //string or buffer
924 key?: any; //string or buffer
925 passphrase?: string;
926 cert?: any;
927 ca?: any; //string or buffer
928 crl?: any; //string or string array
929 ciphers?: string;
930 honorCipherOrder?: any;
931 requestCert?: boolean;
932 rejectUnauthorized?: boolean;
933 NPNProtocols?: any; //array or Buffer;
934 SNICallback?: (servername: string) => any;
935 }
936
937 export interface ConnectionOptions {
938 host?: string;
939 port?: number;
940 socket?: net.NodeSocket;
941 pfx?: any; //string | Buffer
942 key?: any; //string | Buffer
943 passphrase?: string;
944 cert?: any; //string | Buffer
945 ca?: any; //Array of string | Buffer
946 rejectUnauthorized?: boolean;
947 NPNProtocols?: any; //Array of string | Buffer
948 servername?: string;
949 }
950
951 export interface Server extends net.Server {
952 // Extended base methods
953 listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void;
954 listen(path: string, listeningListener?: Function): void;
955 listen(handle: any, listeningListener?: Function): void;
956
957 listen(port: number, host?: string, callback?: Function): void;
958 close(): void;
959 address(): { port: number; family: string; address: string; };
960 addContext(hostName: string, credentials: {
961 key: string;
962 cert: string;
963 ca: string;
964 }): void;
965 maxConnections: number;
966 connections: number;
967 }
968
969 export interface ClearTextStream extends ReadWriteStream {
970 authorized: boolean;
971 authorizationError: Error;
972 getPeerCertificate(): any;
973 getCipher: {
974 name: string;
975 version: string;
976 };
977 address: {
978 port: number;
979 family: string;
980 address: string;
981 };
982 remoteAddress: string;
983 remotePort: number;
984 }
985
986 export interface SecurePair {
987 encrypted: any;
988 cleartext: any;
989 }
990
991 export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) => void): Server;
992 export function connect(options: TlsOptions, secureConnectionListener?: () => void): ClearTextStream;
993 export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
994 export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream;
995 export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
996}
997
998declare module "crypto" {
999 export interface CredentialDetails {
1000 pfx: string;
1001 key: string;
1002 passphrase: string;
1003 cert: string;
1004 ca: any; //string | string array
1005 crl: any; //string | string array
1006 ciphers: string;
1007 }
1008 export interface Credentials { context?: any; }
1009 export function createCredentials(details: CredentialDetails): Credentials;
1010 export function createHash(algorithm: string): Hash;
1011 export function createHmac(algorithm: string, key: string): Hmac;
1012 interface Hash {
1013 update(data: any, input_encoding?: string): Hash;
1014 digest(encoding?: string): string;
1015 }
1016 interface Hmac {
1017 update(data: any): void;
1018 digest(encoding?: string): void;
1019 }
1020 export function createCipher(algorithm: string, password: any): Cipher;
1021 export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
1022 interface Cipher {
1023 update(data: any, input_encoding?: string, output_encoding?: string): string;
1024 final(output_encoding?: string): string;
1025 setAutoPadding(auto_padding: boolean): void;
1026 createDecipher(algorithm: string, password: any): Decipher;
1027 createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
1028 }
1029 interface Decipher {
1030 update(data: any, input_encoding?: string, output_encoding?: string): void;
1031 final(output_encoding?: string): string;
1032 setAutoPadding(auto_padding: boolean): void;
1033 }
1034 export function createSign(algorithm: string): Signer;
1035 interface Signer {
1036 update(data: any): void;
1037 sign(private_key: string, output_format: string): string;
1038 }
1039 export function createVerify(algorith: string): Verify;
1040 interface Verify {
1041 update(data: any): void;
1042 verify(object: string, signature: string, signature_format?: string): boolean;
1043 }
1044 export function createDiffieHellman(prime_length: number): DiffieHellman;
1045 export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman;
1046 interface DiffieHellman {
1047 generateKeys(encoding?: string): string;
1048 computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string;
1049 getPrime(encoding?: string): string;
1050 getGenerator(encoding: string): string;
1051 getPublicKey(encoding?: string): string;
1052 getPrivateKey(encoding?: string): string;
1053 setPublicKey(public_key: string, encoding?: string): void;
1054 setPrivateKey(public_key: string, encoding?: string): void;
1055 }
1056 export function getDiffieHellman(group_name: string): DiffieHellman;
1057 export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void;
1058 export function randomBytes(size: number): NodeBuffer;
1059 export function randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) => void): void;
1060 export function pseudoRandomBytes(size: number): NodeBuffer;
1061 export function pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) => void): void;
1062}
1063
1064declare module "stream" {
1065 import events = require("events");
1066
1067 export interface ReadableOptions {
1068 highWaterMark?: number;
1069 encoding?: string;
1070 objectMode?: boolean;
1071 }
1072
1073 export class Readable extends events.EventEmitter implements ReadableStream {
1074 readable: boolean;
1075 constructor(opts?: ReadableOptions);
1076 _read(size: number): void;
1077 read(size?: number): any;
1078 setEncoding(encoding: string): void;
1079 pause(): void;
1080 resume(): void;
1081 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
1082 unpipe<T extends WritableStream>(destination?: T): void;
1083 unshift(chunk: string): void;
1084 unshift(chunk: NodeBuffer): void;
1085 wrap(oldStream: ReadableStream): ReadableStream;
1086 push(chunk: any, encoding?: string): boolean;
1087 }
1088
1089 export interface WritableOptions {
1090 highWaterMark?: number;
1091 decodeStrings?: boolean;
1092 }
1093
1094 export class Writable extends events.EventEmitter implements WritableStream {
1095 writable: boolean;
1096 constructor(opts?: WritableOptions);
1097 _write(data: NodeBuffer, encoding: string, callback: Function): void;
1098 _write(data: string, encoding: string, callback: Function): void;
1099 write(buffer: NodeBuffer, cb?: Function): boolean;
1100 write(str: string, cb?: Function): boolean;
1101 write(str: string, encoding?: string, cb?: Function): boolean;
1102 end(): void;
1103 end(buffer: NodeBuffer, cb?: Function): void;
1104 end(str: string, cb?: Function): void;
1105 end(str: string, encoding?: string, cb?: Function): void;
1106 }
1107
1108 export interface DuplexOptions extends ReadableOptions, WritableOptions {
1109 allowHalfOpen?: boolean;
1110 }
1111
1112 // Note: Duplex extends both Readable and Writable.
1113 export class Duplex extends Readable implements ReadWriteStream {
1114 writable: boolean;
1115 constructor(opts?: DuplexOptions);
1116 _write(data: NodeBuffer, encoding: string, callback: Function): void;
1117 _write(data: string, encoding: string, callback: Function): void;
1118 write(buffer: NodeBuffer, cb?: Function): boolean;
1119 write(str: string, cb?: Function): boolean;
1120 write(str: string, encoding?: string, cb?: Function): boolean;
1121 end(): void;
1122 end(buffer: NodeBuffer, cb?: Function): void;
1123 end(str: string, cb?: Function): void;
1124 end(str: string, encoding?: string, cb?: Function): void;
1125 }
1126
1127 export interface TransformOptions extends ReadableOptions, WritableOptions { }
1128
1129 // Note: Transform lacks the _read and _write methods of Readable/Writable.
1130 export class Transform extends events.EventEmitter implements ReadWriteStream {
1131 readable: boolean;
1132 writable: boolean;
1133 constructor(opts?: TransformOptions);
1134 _transform(chunk: NodeBuffer, encoding: string, callback: Function): void;
1135 _transform(chunk: string, encoding: string, callback: Function): void;
1136 _flush(callback: Function): void;
1137 read(size?: number): any;
1138 setEncoding(encoding: string): void;
1139 pause(): void;
1140 resume(): void;
1141 pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
1142 unpipe<T extends WritableStream>(destination?: T): void;
1143 unshift(chunk: string): void;
1144 unshift(chunk: NodeBuffer): void;
1145 wrap(oldStream: ReadableStream): ReadableStream;
1146 push(chunk: any, encoding?: string): boolean;
1147 write(buffer: NodeBuffer, cb?: Function): boolean;
1148 write(str: string, cb?: Function): boolean;
1149 write(str: string, encoding?: string, cb?: Function): boolean;
1150 end(): void;
1151 end(buffer: NodeBuffer, cb?: Function): void;
1152 end(str: string, cb?: Function): void;
1153 end(str: string, encoding?: string, cb?: Function): void;
1154 }
1155
1156 export class PassThrough extends Transform { }
1157}
1158
1159declare module "util" {
1160 export interface InspectOptions {
1161 showHidden?: boolean;
1162 depth?: number;
1163 colors?: boolean;
1164 customInspect?: boolean;
1165 }
1166
1167 export function format(format: any, ...param: any[]): string;
1168 export function debug(string: string): void;
1169 export function error(...param: any[]): void;
1170 export function puts(...param: any[]): void;
1171 export function print(...param: any[]): void;
1172 export function log(string: string): void;
1173 export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string;
1174 export function inspect(object: any, options: InspectOptions): string;
1175 export function isArray(object: any): boolean;
1176 export function isRegExp(object: any): boolean;
1177 export function isDate(object: any): boolean;
1178 export function isError(object: any): boolean;
1179 export function inherits(constructor: any, superConstructor: any): void;
1180}
1181
1182declare module "assert" {
1183 function internal(value: any, message?: string): void;
1184 module internal {
1185 export class AssertionError implements Error {
1186 name: string;
1187 message: string;
1188 actual: any;
1189 expected: any;
1190 operator: string;
1191 generatedMessage: boolean;
1192
1193 constructor(options?: {
1194 message?: string; actual?: any; expected?: any;
1195 operator?: string; stackStartFunction?: Function
1196 });
1197 }
1198
1199 export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
1200 export function ok(value: any, message?: string): void;
1201 export function equal(actual: any, expected: any, message?: string): void;
1202 export function notEqual(actual: any, expected: any, message?: string): void;
1203 export function deepEqual(actual: any, expected: any, message?: string): void;
1204 export function notDeepEqual(acutal: any, expected: any, message?: string): void;
1205 export function strictEqual(actual: any, expected: any, message?: string): void;
1206 export function notStrictEqual(actual: any, expected: any, message?: string): void;
1207 export var throws: {
1208 (block: Function, message?: string): void;
1209 (block: Function, error: Function, message?: string): void;
1210 (block: Function, error: RegExp, message?: string): void;
1211 (block: Function, error: (err: any) => boolean, message?: string): void;
1212 }
1213
1214 export var doesNotThrow: {
1215 (block: Function, message?: string): void;
1216 (block: Function, error: Function, message?: string): void;
1217 (block: Function, error: RegExp, message?: string): void;
1218 (block: Function, error: (err: any) => boolean, message?: string): void;
1219 }
1220
1221 export function ifError(value: any): void;
1222 }
1223
1224 export = internal;
1225}
1226
1227declare module "tty" {
1228 import net = require("net");
1229
1230 export function isatty(fd: number): boolean;
1231 export interface ReadStream extends net.NodeSocket {
1232 isRaw: boolean;
1233 setRawMode(mode: boolean): void;
1234 }
1235 export interface WriteStream extends net.NodeSocket {
1236 columns: number;
1237 rows: number;
1238 }
1239}
1240
1241declare module "domain" {
1242 import events = require("events");
1243
1244 export class Domain extends events.EventEmitter {
1245 run(fn: Function): void;
1246 add(emitter: NodeEventEmitter): void;
1247 remove(emitter: NodeEventEmitter): void;
1248 bind(cb: (err: Error, data: any) => any): any;
1249 intercept(cb: (data: any) => any): any;
1250 dispose(): void;
1251
1252 addListener(event: string, listener: Function): Domain;
1253 on(event: string, listener: Function): Domain;
1254 once(event: string, listener: Function): Domain;
1255 removeListener(event: string, listener: Function): Domain;
1256 removeAllListeners(event?: string): Domain;
1257 }
1258
1259 export function create(): Domain;
1260}