PageRenderTime 68ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/temp/node.d.ts.for.stopping.console.duplicate.error

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