microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9508f4d85629a366872b2c091ec19a44d08fa060

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tools/typings/node/node.d.ts

2217lines · modecode

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