From 368266b684bfa07c8d2ae1934e342add8be624aa Mon Sep 17 00:00:00 2001 From: Troy Gerwien Date: Sat, 29 Mar 2014 21:21:41 +0800 Subject: [PATCH] var-interface-module pattern now consistent Everything (in both node and express) now follows the pattern: ``` declare module "external-name" { import _ = InternalName.InnerName; export = _; } declare module InternalName { export var InnerName: InnerName; export interface InnerName { // functions and vars in here } export module InnerName { // Must be non-instantiated - so only interfaces and modules in here } } ``` --- express/express.d.ts | 130 ++++++++++----------------- node/node.d.ts | 207 +++++++++++++++++++++++-------------------- 2 files changed, 160 insertions(+), 177 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index b7331a43d7..049871c350 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -12,13 +12,15 @@ /// -declare module "express" { var _: ExpressStatic; export = _; } -interface ExpressStatic{ - (): ExpressStatic.Express +declare module "express" { + import _ = Express.Static; + export = _; } -declare module ExpressStatic { +declare module Express { + export var Static: Static; + export module Static { - export interface IRoute { + export interface Route { path: string; method: string; @@ -32,17 +34,6 @@ declare module ExpressStatic { * populate `.params`. */ match(path: string): boolean; - } - - export class Route implements IRoute { - path: string; - - method: string; - - callbacks: Function[]; - - regexp: any; - match(path: string): boolean; /** * Initialize `Route` with the given HTTP `method`, `path`, @@ -129,40 +120,10 @@ declare module ExpressStatic { patch(name: RegExp, ...handlers: RequestFunction[]): T; } - export class Router implements IRouter { - new (options?: any): Router; + export interface Router extends IRouter { + new (options?: any): Router; - middleware (): any; - - param(name: string, fn: Function): Router; - - param(name: any[], fn: Function): Router; - - all(path: string, fn?: (req: Request, res: Response, next: Function) => any): Router; - - all(path: string, ...callbacks: Function[]): void; - - get(name: string): string; - - get(name: string, ...handlers: RequestFunction[]): Router; - - get(name: RegExp, ...handlers: RequestFunction[]): Router; - - post(name: string, ...handlers: RequestFunction[]): Router; - - post(name: RegExp, ...handlers: RequestFunction[]): Router; - - put(name: string, ...handlers: RequestFunction[]): Router; - - put(name: RegExp, ...handlers: RequestFunction[]): Router; - - del(name: string, ...handlers: RequestFunction[]): Router; - - del(name: RegExp, ...handlers: RequestFunction[]): Router; - - patch(name: string, ...handlers: RequestFunction[]): Router; - - patch(name: RegExp, ...handlers: RequestFunction[]): Router; + middleware (): any; } export interface Handler { @@ -1125,7 +1086,7 @@ declare module ExpressStatic { listen(handle: any, listeningListener?: Function): void; - route: IRoute; + route: Route; router: string; @@ -1174,6 +1135,9 @@ declare module ExpressStatic { response: Response; } + } + interface Static { + (): Express.Static.Express; /** * Body parser: @@ -1202,7 +1166,7 @@ declare module ExpressStatic { * * @param options */ - export function bodyParser(options?: any): Handler; + bodyParser(options?: any): Express.Static.Handler; /** * Error handler: @@ -1225,7 +1189,7 @@ declare module ExpressStatic { * * When accepted connect will output a nice html stack trace. */ - export function errorHandler(opts?: any): Handler; + errorHandler(opts?: any): Express.Static.Handler; /** * Method Override: @@ -1238,7 +1202,7 @@ declare module ExpressStatic { * * @param key */ - export function methodOverride(key?: string): Handler; + methodOverride(key?: string): Express.Static.Handler; /** * Cookie parser: @@ -1259,7 +1223,7 @@ declare module ExpressStatic { * * @param secret */ - export function cookieParser(secret?: string): Handler; + cookieParser(secret?: string): Express.Static.Handler; /** * Session: @@ -1396,7 +1360,7 @@ declare module ExpressStatic { * * @param options */ - export function session(options?: any): Handler; + session(options?: any): Express.Static.Handler; /** * Hash the given `sess` object omitting changes @@ -1404,7 +1368,7 @@ declare module ExpressStatic { * * @param sess */ - export function hash(sess: string): string; + hash(sess: string): string; /** * Static: @@ -1430,7 +1394,7 @@ declare module ExpressStatic { * @param root * @param options */ - export function static(root: string, options?: any): Handler; + static(root: string, options?: any): Express.Static.Handler; /** * Basic Auth: @@ -1462,11 +1426,11 @@ declare module ExpressStatic { * @param callback or username * @param realm */ - export function basicAuth(callback: (user: string, pass: string, fn : Function) => void, realm?: string): Handler; + basicAuth(callback: (user: string, pass: string, fn : Function) => void, realm?: string): Express.Static.Handler; - export function basicAuth(callback: (user: string, pass: string) => boolean, realm?: string): Handler; + basicAuth(callback: (user: string, pass: string) => boolean, realm?: string): Express.Static.Handler; - export function basicAuth(user: string, pass: string, realm?: string): Handler; + basicAuth(user: string, pass: string, realm?: string): Express.Static.Handler; /** * Compress: @@ -1495,7 +1459,7 @@ declare module ExpressStatic { * * @param options */ - export function compress(options?: any): Handler; + compress(options?: any): Express.Static.Handler; /** * Cookie Session: @@ -1522,7 +1486,7 @@ declare module ExpressStatic { * * @param options */ - export function cookieSession(options?: any): Handler; + cookieSession(options?: any): Express.Static.Handler; /** * Anti CSRF: @@ -1547,7 +1511,7 @@ declare module ExpressStatic { * * @param options */ - export function csrf(options?: {value?: Function}): Handler; + csrf(options?: {value?: Function}): Express.Static.Handler; /** * Directory: @@ -1563,7 +1527,7 @@ declare module ExpressStatic { * @param root * @param options */ - export function directory(root: string, options?: any): Handler; + directory(root: string, options?: any): Express.Static.Handler; /** * Favicon: @@ -1596,7 +1560,7 @@ declare module ExpressStatic { * @param path * @param options */ - export function favicon(path?: string, options?: any): Handler; + favicon(path?: string, options?: any): Express.Static.Handler; /** * JSON: @@ -1612,7 +1576,7 @@ declare module ExpressStatic { * * @param options */ - export function json(options?: any): Handler; + json(options?: any): Express.Static.Handler; /** * Limit: @@ -1626,9 +1590,9 @@ declare module ExpressStatic { * .use(connect.limit('5.5mb')) * .use(handleImageUpload) */ - export function limit(bytes: number): Handler; + limit(bytes: number): Express.Static.Handler; - export function limit(bytes: string): Handler; + limit(bytes: string): Express.Static.Handler; /** * Logger: @@ -1689,18 +1653,18 @@ declare module ExpressStatic { * * connect.logger.format('name', 'string or function') */ - export function logger(options: string): Handler; + logger(options: string): Express.Static.Handler; - export function logger(options: Function): Handler; + logger(options: Function): Express.Static.Handler; - export function logger(options?: any): Handler; + logger(options?: any): Express.Static.Handler; /** * Compile `fmt` into a function. * * @param fmt */ - export function compile(fmt: string): Handler; + compile(fmt: string): Express.Static.Handler; /** * Define a token function with the given `name`, @@ -1709,14 +1673,14 @@ declare module ExpressStatic { * @param name * @param fn */ - export function token(name: string, fn: Function): any; + token(name: string, fn: Function): any; /** * Define a `fmt` with the given `name`. */ - export function format(name: string, str: string): any; + format(name: string, str: string): any; - export function format(name: string, str: Function): any; + format(name: string, str: Function): any; /** * Query: @@ -1734,7 +1698,7 @@ declare module ExpressStatic { * * The `options` passed are provided to qs.parse function. */ - export function query(options: any): Handler; + query(options: any): Express.Static.Handler; /** * Reponse time: @@ -1742,7 +1706,7 @@ declare module ExpressStatic { * Adds the `X-Response-Time` header displaying the response * duration in milliseconds. */ - export function responseTime(): Handler; + responseTime(): Express.Static.Handler; /** * Static cache: @@ -1774,7 +1738,7 @@ declare module ExpressStatic { * - `maxObjects` max cache objects [128] * - `maxLength` max cache object length 256kb */ - export function staticCache(options: any): Handler; + staticCache(options: any): Express.Static.Handler; /** * Timeout: @@ -1787,7 +1751,7 @@ declare module ExpressStatic { * the response behaviour. This error has the `.timeout` property as * well as `.status == 408`. */ - export function timeout(ms: number): Handler; + timeout(ms: number): Express.Static.Handler; /** * Vhost: @@ -1805,10 +1769,10 @@ declare module ExpressStatic { * @param hostname * @param server */ - export function vhost(hostname: string, server: any): Handler; + vhost(hostname: string, server: any): Express.Static.Handler; - export function urlencoded(): any; + urlencoded(): any; - export function multipart(): any; + multipart(): any; + } } - diff --git a/node/node.d.ts b/node/node.d.ts index f82ffe2023..f98400c462 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -225,32 +225,32 @@ interface NodeTimer { * * ************************************************/ -declare module "querystring" { var _: NodeJs.QueryString; export = _; } -declare module "events" { var _: NodeJs.Events; export = _; } -declare module "http" { var _: NodeJs.Http; export = _; } -declare module "cluster" { var _: NodeJs.Cluster; export = _; } -declare module "zlib" { var _: NodeJs.Zlib; export = _; } -declare module "os" { var _: NodeJs.Os; export = _; } -declare module "https" { var _: NodeJs.Https; export = _; } -declare module "punycode" { var _: NodeJs.PunyCode; export = _; } -declare module "repl" { var _: NodeJs.Repl; export = _; } -declare module "readline" { var _: NodeJs.ReadLine; export = _; } -declare module "vm" { var _: NodeJs.Vm; export = _; } -declare module "child_process" { var _: NodeJs.ChildProcess; export = _; } -declare module "url" { var _: NodeJs.Url; export = _; } -declare module "dns" { var _: NodeJs.Dns; export = _; } -declare module "net" { var _: NodeJs.Net; export = _; } -declare module "dgram" { var _: NodeJs.Dgram; export = _; } -declare module "fs" { var _: NodeJs.Fs; export = _; } -declare module "path" { var _: NodeJs.Path; export = _; } -declare module "string_decoder" { var _: NodeJs.StringDecoder; export = _; } -declare module "tls" { var _: NodeJs.Tls; export = _; } -declare module "crypto" { var _: NodeJs.Crypto; export = _; } -declare module "stream" { var _: NodeJs.Stream; export = _; } -declare module "util" { var _: NodeJs.Util; export = _; } -declare module "assert" { var _: NodeJs.Assert; export = _; } -declare module "tty" { var _: NodeJs.Tty; export = _; } -declare module "domain" { var _: NodeJs.Domain; export = _; } +declare module "querystring" { import _ = NodeJs.QueryString; export = _; } +declare module "events" { import _ = NodeJs.Events; export = _; } +declare module "http" { import _ = NodeJs.Http; export = _; } +declare module "cluster" { import _ = NodeJs.Cluster; export = _; } +declare module "zlib" { import _ = NodeJs.Zlib; export = _; } +declare module "os" { import _ = NodeJs.Os; export = _; } +declare module "https" { import _ = NodeJs.Https; export = _; } +declare module "punycode" { import _ = NodeJs.PunyCode; export = _; } +declare module "repl" { import _ = NodeJs.Repl; export = _; } +declare module "readline" { import _ = NodeJs.ReadLine; export = _; } +declare module "vm" { import _ = NodeJs.Vm; export = _; } +declare module "child_process" { import _ = NodeJs.ChildProcess; export = _; } +declare module "url" { import _ = NodeJs.Url; export = _; } +declare module "dns" { import _ = NodeJs.Dns; export = _; } +declare module "net" { import _ = NodeJs.Net; export = _; } +declare module "dgram" { import _ = NodeJs.Dgram; export = _; } +declare module "fs" { import _ = NodeJs.Fs; export = _; } +declare module "path" { import _ = NodeJs.Path; export = _; } +declare module "string_decoder" { import _ = NodeJs.StringDecoder; export = _; } +declare module "tls" { import _ = NodeJs.Tls; export = _; } +declare module "crypto" { import _ = NodeJs.Crypto; export = _; } +declare module "stream" { import _ = NodeJs.Stream; export = _; } +declare module "util" { import _ = NodeJs.Util; export = _; } +declare module "assert" { import _ = NodeJs.Assert; export = _; } +declare module "tty" { import _ = NodeJs.Tty; export = _; } +declare module "domain" { import _ = NodeJs.Domain; export = _; } /************************************************ * * @@ -260,15 +260,20 @@ declare module "domain" { var _: NodeJs.Domain; export = _; } declare module NodeJs { - // "querystring" module + + // ---------- "querystring" module ---------- + export var QueryString: QueryString; export interface QueryString { stringify(obj: any, sep?: string, eq?: string): string; parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; escape(): any; unescape(): any; } + export module QueryString { } - // "events" module + + // ---------- "events" module ---------- + export var Events: Events; export interface Events { EventEmitter: Events.EventEmitterStatic; } @@ -276,7 +281,6 @@ declare module NodeJs { export interface EventEmitterStatic { listenerCount(emitter: EventEmitter, event: string): number; } - export interface EventEmitter extends NodeEventEmitter { addListener(event: string, listener: Function): EventEmitter; on(event: string, listener: Function): EventEmitter; @@ -289,7 +293,9 @@ declare module NodeJs { } } - // "http" module + + // ---------- "http" module ---------- + export var Http: Http; export interface Http { STATUS_CODES: any; createServer(requestListener?: (request: Http.ServerRequest, response: Http.ServerResponse) =>void ): Http.Server; @@ -299,7 +305,6 @@ declare module NodeJs { globalAgent: Http.Agent; } export module Http { - export interface Server extends NodeEventEmitter { listen(port: number, hostname?: string, backlog?: number, callback?: Function): void; listen(path: string, callback?: Function): void; @@ -319,6 +324,7 @@ declare module NodeJs { connection: Net.Socket; } export interface ServerResponse extends NodeEventEmitter, WritableStream { + // Extended base methods write(buffer: NodeBuffer): boolean; write(buffer: NodeBuffer, cb?: Function): boolean; @@ -345,6 +351,7 @@ declare module NodeJs { end(data?: any, encoding?: string): void; } export interface ClientRequest extends NodeEventEmitter, WritableStream { + // Extended base methods write(buffer: NodeBuffer): boolean; write(buffer: NodeBuffer, cb?: Function): boolean; @@ -377,7 +384,9 @@ declare module NodeJs { export interface Agent { maxSockets: number; sockets: any; requests: any; } } - // "cluster" module + + // ---------- "cluster" module ---------- + export var Cluster: Cluster; export interface Cluster { settings: Cluster.ClusterSettings; isMaster: boolean; @@ -399,13 +408,11 @@ declare module NodeJs { emit(event: string, ...args: any[]): boolean; } export module Cluster { - export interface ClusterSettings { exec?: string; args?: string[]; silent?: boolean; } - export interface Worker extends Events.EventEmitter { id: string; process: ChildProcess.ChildProcess; @@ -417,7 +424,9 @@ declare module NodeJs { } } - // "zlib" module + + // ---------- "zlib" module ---------- + export var Zlib: Zlib; export interface Zlib { createGzip(options?: Zlib.ZlibOptions): Zlib.Gzip; createGunzip(options?: Zlib.ZlibOptions): Zlib.Gunzip; @@ -469,9 +478,7 @@ declare module NodeJs { Z_NULL: number; } export module Zlib { - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - export interface Gzip extends ReadWriteStream { } export interface Gunzip extends ReadWriteStream { } export interface Deflate extends ReadWriteStream { } @@ -481,7 +488,9 @@ declare module NodeJs { export interface Unzip extends ReadWriteStream { } } - // "os" module + + // ---------- "os" module ---------- + export var Os: Os; export interface Os { tmpDir(): string; hostname(): string; @@ -497,8 +506,11 @@ declare module NodeJs { networkInterfaces(): any; EOL: string; } + export module Os { } - // "https" module + + // ---------- "https" module ---------- + export var Https: Https; export interface Https { Agent: new(options?: Https.RequestOptions) => Https.Agent; @@ -508,7 +520,6 @@ declare module NodeJs { globalAgent: Https.Agent; } export module Https { - export interface ServerOptions { pfx?: any; key?: any; @@ -523,7 +534,6 @@ declare module NodeJs { NPNProtocols?: any; SNICallback?: (servername: string) => any; } - export interface RequestOptions { host?: string; hostname?: string; @@ -541,7 +551,6 @@ declare module NodeJs { ciphers?: string; rejectUnauthorized?: boolean; } - export interface Agent { maxSockets: number; sockets: any; @@ -550,7 +559,9 @@ declare module NodeJs { export interface Server extends Tls.Server { } } - // "punycode" module + + // ---------- "punycode" module ---------- + export var PunyCode: PunyCode; export interface PunyCode { decode(string: string): string; encode(string: string): string; @@ -562,13 +573,15 @@ declare module NodeJs { } version: any; } + export module PunyCode { } - // "repl" module + + // ---------- "repl" module ---------- + export var Repl: Repl; export interface Repl { start(options: Repl.ReplOptions): NodeEventEmitter; } export module Repl { - export interface ReplOptions { prompt?: string; input?: ReadableStream; @@ -582,12 +595,13 @@ declare module NodeJs { } } - // "readline" module + + // ---------- "readline" module ---------- + export var ReadLine: ReadLine; export interface ReadLine { createInterface(options: ReadLine.ReadLineOptions): ReadLine.ReadLine; } export module ReadLine { - export interface ReadLine extends NodeEventEmitter { setPrompt(prompt: string, length: number): void; prompt(preserveCursor?: boolean): void; @@ -605,7 +619,9 @@ declare module NodeJs { } } - // "vm" module + + // ---------- "vm" module ---------- + export var Vm: Vm; export interface Vm { runInThisContext(code: string, filename?: string): void; runInNewContext(code: string, sandbox?: Vm.Context, filename?: string): void; @@ -621,7 +637,9 @@ declare module NodeJs { } } - // "child_process" module + + // ---------- "child_process" module ---------- + export var ChildProcess: ChildProcess; export interface ChildProcess { spawn(command: string, args?: string[], options?: { cwd?: string; @@ -658,7 +676,6 @@ declare module NodeJs { }): ChildProcess.ChildProcess; } export module ChildProcess { - export interface ChildProcess extends NodeEventEmitter { stdin: WritableStream; stdout: ReadableStream; @@ -670,7 +687,9 @@ declare module NodeJs { } } - // "url" module + + // ---------- "url" module ---------- + export var Url: Url; export interface Url { parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url.Url; format(url: Url.UrlOptions): string; @@ -689,7 +708,6 @@ declare module NodeJs { query: string; slashes: boolean; } - export interface UrlOptions { protocol?: string; auth?: string; @@ -702,7 +720,9 @@ declare module NodeJs { } } - // "dns" module + + // ---------- "dns" module ---------- + export var Dns: Dns; export interface Dns { lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; @@ -717,8 +737,11 @@ declare module NodeJs { resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; } + export module Dns { } - // "net" module + + // ---------- "net" module ---------- + export var Net: Net; export interface Net { Socket: new(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }) => Net.Socket; @@ -735,8 +758,8 @@ declare module NodeJs { isIPv6(input: string): boolean; } export module Net { - export interface Socket extends ReadWriteStream { + // Extended base methods write(buffer: NodeBuffer): boolean; write(buffer: NodeBuffer, cb?: Function): boolean; @@ -768,7 +791,6 @@ declare module NodeJs { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface Server extends Socket { listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void; listen(path: string, listeningListener?: Function): void; @@ -780,12 +802,13 @@ declare module NodeJs { } } - // "dgram" module + + // ---------- "dgram" module ---------- + export var Dgram: Dgram; export interface Dgram { createSocket(type: string, callback?: Function): Dgram.Socket; } export module Dgram { - interface Socket extends NodeEventEmitter { send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; @@ -799,7 +822,9 @@ declare module NodeJs { } } - // "fs" module + + // ---------- "fs" module ---------- + export var Fs: Fs; export interface Fs { rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void; renameSync(oldPath: string, newPath: string): void; @@ -915,7 +940,6 @@ declare module NodeJs { }): Fs.WriteStream; } export module Fs { - export interface Stats { isFile(): boolean; isDirectory(): boolean; @@ -938,16 +962,16 @@ declare module NodeJs { mtime: Date; ctime: Date; } - export interface FSWatcher extends NodeEventEmitter { close(): void; } - export interface ReadStream extends ReadableStream { } export interface WriteStream extends WritableStream { } } - // "path" module + + // ---------- "path" module ---------- + export var Path: Path; export interface Path { normalize(p: string): string; join(...paths: any[]): string; @@ -958,11 +982,13 @@ declare module NodeJs { extname(p: string): string; sep: string; } + export module Path { } - // "string_decoder" module + + // ---------- "string_decoder" module ---------- + export var StringDecoder: StringDecoder; export interface StringDecoder { StringDecoder: new(encoding: string) => StringDecoder.StringDecoder; - } export module StringDecoder { export interface StringDecoder { @@ -971,7 +997,9 @@ declare module NodeJs { } } - // "tls" module + + // ---------- "tls" module ---------- + export var Tls: Tls; export interface Tls { CLIENT_RENEG_LIMIT: number; CLIENT_RENEG_WINDOW: number; @@ -982,7 +1010,6 @@ declare module NodeJs { createSecurePair(credentials?: Crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): Tls.SecurePair; } export module Tls { - export interface TlsOptions { pfx?: any; //string or buffer key?: any; //string or buffer @@ -997,7 +1024,6 @@ declare module NodeJs { NPNProtocols?: any; //array or Buffer; SNICallback?: (servername: string) => any; } - export interface ConnectionOptions { host?: string; port?: number; @@ -1011,7 +1037,6 @@ declare module NodeJs { NPNProtocols?: any; //Array of string | Buffer servername?: string; } - export interface Server extends Net.Server { // Extended base methods listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void; @@ -1029,7 +1054,6 @@ declare module NodeJs { maxConnections: number; connections: number; } - export interface ClearTextStream extends ReadWriteStream { authorized: boolean; authorizationError: Error; @@ -1046,14 +1070,15 @@ declare module NodeJs { remoteAddress: string; remotePort: number; } - export interface SecurePair { encrypted: any; cleartext: any; } } - // "crypto" module + + // ---------- "crypto" module ---------- + export var Crypto: Crypto; export interface Crypto { createCredentials(details: Crypto.CredentialDetails): Crypto.Credentials; createHash(algorithm: string): Crypto.Hash; @@ -1070,7 +1095,6 @@ declare module NodeJs { randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; pseudoRandomBytes(size: number): NodeBuffer; pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; - } export module Crypto { export interface CredentialDetails { @@ -1123,7 +1147,9 @@ declare module NodeJs { } } - // "stream" module + + // ---------- "stream" module ---------- + export var Stream: Stream; export interface Stream { Readable: new(opts?: Stream.ReadableOptions) => Stream.Readable; Writable: new(opts?: Stream.WritableOptions) => Stream.Writable; @@ -1131,13 +1157,11 @@ declare module NodeJs { Transform: new(opts?: Stream.TransformOptions) => Stream.Transform; } export module Stream { - export interface ReadableOptions { highWaterMark?: number; encoding?: string; objectMode?: boolean; } - export interface Readable extends Events.EventEmitter, ReadableStream { readable: boolean; _read(size: number): void; @@ -1152,12 +1176,10 @@ declare module NodeJs { wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; } - export interface WritableOptions { highWaterMark?: number; decodeStrings?: boolean; } - export interface Writable extends Events.EventEmitter, WritableStream { writable: boolean; _write(data: NodeBuffer, encoding: string, callback: Function): void; @@ -1170,7 +1192,6 @@ declare module NodeJs { end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } - export interface DuplexOptions extends ReadableOptions, WritableOptions { allowHalfOpen?: boolean; } @@ -1188,7 +1209,6 @@ declare module NodeJs { end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } - export interface TransformOptions extends ReadableOptions, WritableOptions {} // Note: Transform lacks the _read and _write methods of Readable/Writable. @@ -1216,11 +1236,12 @@ declare module NodeJs { end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } - export interface PassThrough extends Transform {} } - // "util" module + + // ---------- "util" module ---------- + export var Util: Util; export interface Util { format(format: any, ...param: any[]): string; debug(string: string): void; @@ -1245,7 +1266,9 @@ declare module NodeJs { } } - // "assert" module + + // ---------- "assert" module ---------- + export var Assert: Assert; export interface Assert { (value: any, message?: string): void; AssertionError: new(options?: Assert.AssertionErrorOptions) => Assert.AssertionError; @@ -1264,18 +1287,15 @@ declare module NodeJs { (block: Function, error: RegExp, message?: string): void; (block: Function, error: (err: any) => boolean, message?: string): void; } - doesNotThrow: { (block: Function, message?: string): void; (block: Function, error: Function, message?: string): void; (block: Function, error: RegExp, message?: string): void; (block: Function, error: (err: any) => boolean, message?: string): void; } - ifError(value: any): void; } export module Assert { - export interface AssertionErrorOptions { message?: string; actual?: any; @@ -1283,8 +1303,8 @@ declare module NodeJs { operator?: string; stackStartFunction?: Function } - export interface AssertionError extends Error { + new(options?: AssertionErrorOptions): AssertionError; name: string; message: string; actual: any; @@ -1294,15 +1314,15 @@ declare module NodeJs { } } - // "tty" module + + // ---------- "tty" module ---------- + export var Tty: Tty; export interface Tty { ReadStream: new() => Tty.ReadStream; WriteStream: new() => Tty.WriteStream; - isatty(fd: number): boolean; } export module Tty { - export interface ReadStream extends Net.Socket { isRaw: boolean; setRawMode(mode: boolean): void; @@ -1313,14 +1333,14 @@ declare module NodeJs { } } - // "domain" module + + // ---------- "domain" module ---------- + export var Domain: Domain; export interface Domain { Domain: new() => Domain.Domain; - create(): Domain.Domain; } export module Domain { - export interface Domain extends Events.EventEmitter { run(fn: Function): void; add(emitter: NodeEventEmitter): void; @@ -1335,6 +1355,5 @@ declare module NodeJs { removeListener(event: string, listener: Function): Domain; removeAllListeners(event?: string): Domain; } - } }