From 1d451a05e18067cfc61414685f70115cdab0dd97 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sun, 6 Apr 2014 18:23:39 +0400 Subject: [PATCH 1/6] node: NodeBuffer -> Buffer. Mark NodeBuffer as deprecated --- buffer-equal/buffer-equal-tests.ts | 2 +- buffer-equal/buffer-equal.d.ts | 2 +- couchbase/couchbase.d.ts | 8 +- graceful-fs/graceful-fs-tests.ts | 2 +- gruntjs/gruntjs.d.ts | 10 +- node-ffi/node-ffi.d.ts | 180 ++++++++++++++--------------- node/node-0.8.8.d.ts | 80 ++++++------- node/node-tests.ts | 2 +- node/node.d.ts | 131 +++++++++++---------- q-io/Q-io-tests.ts | 8 +- q-io/Q-io.d.ts | 28 ++--- superagent/superagent.d.ts | 2 +- websocket/websocket.d.ts | 40 +++---- ws/ws.d.ts | 2 +- 14 files changed, 251 insertions(+), 246 deletions(-) diff --git a/buffer-equal/buffer-equal-tests.ts b/buffer-equal/buffer-equal-tests.ts index 743ed187e..192051ab4 100644 --- a/buffer-equal/buffer-equal-tests.ts +++ b/buffer-equal/buffer-equal-tests.ts @@ -3,6 +3,6 @@ import bufferEqual = require('buffer-equal'); var bool: boolean; -var buf: NodeBuffer; +var buf: Buffer; bool = bufferEqual(buf, buf); diff --git a/buffer-equal/buffer-equal.d.ts b/buffer-equal/buffer-equal.d.ts index bc8b1ce28..5f671662d 100644 --- a/buffer-equal/buffer-equal.d.ts +++ b/buffer-equal/buffer-equal.d.ts @@ -6,6 +6,6 @@ /// declare module 'buffer-equal' { - function bufferEqual(actual:NodeBuffer, expected:NodeBuffer): boolean; + function bufferEqual(actual:Buffer, expected:Buffer): boolean; export = bufferEqual; } diff --git a/couchbase/couchbase.d.ts b/couchbase/couchbase.d.ts index 2b0a720a9..3a8605b73 100644 --- a/couchbase/couchbase.d.ts +++ b/couchbase/couchbase.d.ts @@ -648,8 +648,8 @@ declare module 'couchbase' { append(key: string, fragment: string, callback: KeyCallback): void; append(key: string, fragment: string, options: AppendOptions, callback: KeyCallback): void; - append(key: string, fragment: NodeBuffer, callback: KeyCallback): void; - append(key: string, fragment: NodeBuffer, options: AppendOptions, callback: KeyCallback): void; + append(key: string, fragment: Buffer, callback: KeyCallback): void; + append(key: string, fragment: Buffer, options: AppendOptions, callback: KeyCallback): void; appendMulti(kv: { [key: string]: AppendMultiOptionsForValue }, options: AppendMultiOptions, callback: MultiCallback): void; decr(key: string, callback: KeyCallback): void; @@ -683,8 +683,8 @@ declare module 'couchbase' { prepend(key: string, fragment: string, callback: KeyCallback): void; prepend(key: string, fragment: string, options: PrependOptions, callback: KeyCallback): void; - prepend(key: string, fragment: NodeBuffer, callback: KeyCallback): void; - prepend(key: string, fragment: NodeBuffer, options: PrependOptions, callback: KeyCallback): void; + prepend(key: string, fragment: Buffer, callback: KeyCallback): void; + prepend(key: string, fragment: Buffer, options: PrependOptions, callback: KeyCallback): void; prependMulti(kv: { [key: string]: PrependMultiOptionsFoValue }, options: { [key: string]: PrependMultiOptions }, callback: MultiCallback): void; remove(key: string, callback: KeyCallback): void; diff --git a/graceful-fs/graceful-fs-tests.ts b/graceful-fs/graceful-fs-tests.ts index ca0a5e7b8..5c9bb19ae 100644 --- a/graceful-fs/graceful-fs-tests.ts +++ b/graceful-fs/graceful-fs-tests.ts @@ -3,6 +3,6 @@ import fs = require('graceful-fs'); var str: string; -var buf: NodeBuffer; +var buf: Buffer; fs.renameSync(str, str); \ No newline at end of file diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 2bf0d91b4..86923c56e 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -336,7 +336,7 @@ declare module grunt { * whose return value will be used as the destination file's contents. If * this function returns `false`, the file copy will be aborted. */ - process?: (buffer: NodeBuffer) => boolean + process?: (buffer: Buffer) => boolean } /** @@ -370,21 +370,21 @@ declare module grunt { * Returns a string, unless options.encoding is null in which case it returns a Buffer. */ read(filepath: string): string - read(filepath: string, options: IFileEncodedOption): NodeBuffer + read(filepath: string, options: IFileEncodedOption): Buffer /** * Read a file's contents, parsing the data as JSON and returning the result. * @see FileModule.read for a list of supported options. */ readJSON(filepath: string): any - readJSON(filepath: string, options: IFileEncodedOption): NodeBuffer + readJSON(filepath: string, options: IFileEncodedOption): Buffer /** * Read a file's contents, parsing the data as YAML and returning the result. * @see FileModule.read for a list of supported options. */ readYAML(filepath: string): any - readYAML(filepath: string, options: IFileEncodedOption): NodeBuffer + readYAML(filepath: string, options: IFileEncodedOption): Buffer /** * Write the specified contents to a file, creating intermediate directories if necessary. @@ -394,7 +394,7 @@ declare module grunt { * @param options If an encoding is not specified, default to grunt.file.defaultEncoding. */ write(filepath: string, contents: string, options?: IFileEncodedOption): void - write(filepath: string, contents: NodeBuffer): void + write(filepath: string, contents: Buffer): void /** * Copy a source file to a destination path, creating intermediate directories if necessary. diff --git a/node-ffi/node-ffi.d.ts b/node-ffi/node-ffi.d.ts index 957cf5793..e5ee74621 100644 --- a/node-ffi/node-ffi.d.ts +++ b/node-ffi/node-ffi.d.ts @@ -38,13 +38,13 @@ declare module "ffi" { /** The type of arguments. */ argTypes: ref.Type[]; /** Is set for node-ffi functions. */ - ffi_type: NodeBuffer; + ffi_type: Buffer; abi: number; /** Get a `Callback` pointer of this function type. */ - toPointer(fn: (...args: any[]) => any): NodeBuffer; + toPointer(fn: (...args: any[]) => any): Buffer; /** Get a `ForeignFunction` of this function type. */ - toFunction(buf: NodeBuffer): ForeignFunction; + toFunction(buf: Buffer): ForeignFunction; } /** Creates and returns a type for a C function pointer. */ @@ -67,10 +67,10 @@ declare module "ffi" { * execution. */ export var ForeignFunction: { - new (ptr: NodeBuffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; - new (ptr: NodeBuffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; - (ptr: NodeBuffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; - (ptr: NodeBuffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; + new (ptr: Buffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; + new (ptr: Buffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; + (ptr: Buffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; + (ptr: Buffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; } export interface VariadicForeignFunction { @@ -96,17 +96,17 @@ declare module "ffi" { * contain the same ffi_type argument signature. */ export var VariadicForeignFunction: { - new (ptr: NodeBuffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; - new (ptr: NodeBuffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; - (ptr: NodeBuffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; - (ptr: NodeBuffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; + new (ptr: Buffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; + new (ptr: Buffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; + (ptr: Buffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; + (ptr: Buffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; }; export interface DynamicLibrary { /** Close library, returns the result of the `dlclose` system function. */ close(): number; /** Get a symbol from this library. */ - get(symbol: string): NodeBuffer; + get(symbol: string): Buffer; /** Get the result of the `dlerror` system function. */ error(): string; } @@ -126,8 +126,8 @@ declare module "ffi" { RTLD_GLOBAL: number; RTLD_NOLOAD: number; RTLD_NODELETE: number; - RTLD_NEXT: NodeBuffer; - RTLD_DEFAUL: NodeBuffer; + RTLD_NEXT: Buffer; + RTLD_DEFAUL: Buffer; } new (path?: string, mode?: number): DynamicLibrary; @@ -140,24 +140,24 @@ declare module "ffi" { * accept C callback functions. */ export var Callback: { - new (retType: any, argTypes: any[], abi: number, fn: any): NodeBuffer; - new (retType: any, argTypes: any[], fn: any): NodeBuffer; - (retType: any, argTypes: any[], abi: number, fn: any): NodeBuffer; - (retType: any, argTypes: any[], fn: any): NodeBuffer; + new (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + new (retType: any, argTypes: any[], fn: any): Buffer; + (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + (retType: any, argTypes: any[], fn: any): Buffer; } export var ffiType: { /** Get a `ffi_type *` Buffer appropriate for the given type. */ - (type: ref.Type): NodeBuffer + (type: ref.Type): Buffer /** Get a `ffi_type *` Buffer appropriate for the given type. */ - (type: string): NodeBuffer + (type: string): Buffer FFI_TYPE: StructType; } - export var CIF: (retType: any, types: any[], abi?: any) => NodeBuffer - export var CIF_var: (retType: any, types: any[], numFixedArgs: number, abi?: any) => NodeBuffer; + export var CIF: (retType: any, types: any[], abi?: any) => Buffer + export var CIF_var: (retType: any, types: any[], numFixedArgs: number, abi?: any) => Buffer; export var HAS_OBJC: boolean; - export var FFI_TYPES: {[key: string]: NodeBuffer}; + export var FFI_TYPES: {[key: string]: Buffer}; export var FFI_OK: number; export var FFI_BAD_TYPEDEF: number; export var FFI_BAD_ABI: number; @@ -172,8 +172,8 @@ declare module "ffi" { export var RTLD_GLOBAL: number; export var RTLD_NOLOAD: number; export var RTLD_NODELETE: number; - export var RTLD_NEXT: NodeBuffer; - export var RTLD_DEFAULT: NodeBuffer; + export var RTLD_NEXT: Buffer; + export var RTLD_DEFAULT: Buffer; export var LIB_EXT: string; export var FFI_TYPE: StructType; @@ -198,9 +198,9 @@ declare module "ref" { /** The current level of indirection of the buffer. */ indirection: number; /** To invoke when `ref.get` is invoked on a buffer of this type. */ - get(buffer: NodeBuffer, offset: number): any; + get(buffer: Buffer, offset: number): any; /** To invoke when `ref.set` is invoked on a buffer of this type. */ - set(buffer: NodeBuffer, offset: number, value: any): void; + set(buffer: Buffer, offset: number, value: any): void; /** The name to use during debugging for this datatype. */ name?: string; /** The alignment of this datatype when placed inside a struct. */ @@ -208,22 +208,22 @@ declare module "ref" { } /** A Buffer that references the C NULL pointer. */ - export var NULL: NodeBuffer; + export var NULL: Buffer; /** A pointer-sized buffer pointing to NULL. */ - export var NULL_POINTER: NodeBuffer; + export var NULL_POINTER: Buffer; /** Get the memory address of buffer. */ - export function address(buffer: NodeBuffer): number; + export function address(buffer: Buffer): number; /** Allocate the memory with the given value written to it. */ - export function alloc(type: Type, value?: any): NodeBuffer; + export function alloc(type: Type, value?: any): Buffer; /** Allocate the memory with the given value written to it. */ - export function alloc(type: string, value?: any): NodeBuffer; + export function alloc(type: string, value?: any): Buffer; /** * Allocate the memory with the given string written to it with the given * encoding (defaults to utf8). The buffer is 1 byte longer than the * string itself, and is NULL terminated. */ - export function allocCString(string: string, encoding?: string): NodeBuffer; + export function allocCString(string: string, encoding?: string): Buffer; /** Coerce a type.*/ export function coerceType(type: Type): Type; @@ -236,7 +236,7 @@ declare module "ref" { * if it's greater than 1 then it merely returns another Buffer, but with * one level less indirection. */ - export function deref(buffer: NodeBuffer): any; + export function deref(buffer: Buffer): any; /** Create clone of the type, with decremented indirection level by 1. */ export function derefType(type: Type): Type; @@ -245,51 +245,51 @@ declare module "ref" { /** Represents the native endianness of the processor ("LE" or "BE"). */ export var endianness: string; /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: NodeBuffer, offset?: number, type?: Type): any; + export function get(buffer: Buffer, offset?: number, type?: Type): any; /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: NodeBuffer, offset?: number, type?: string): any; + export function get(buffer: Buffer, offset?: number, type?: string): any; /** Get type of the buffer. Create a default type when none exists. */ - export function getType(buffer: NodeBuffer): Type; + export function getType(buffer: Buffer): Type; /** Check the NULL. */ - export function isNull(buffer: NodeBuffer): boolean; + export function isNull(buffer: Buffer): boolean; /** Read C string until the first NULL. */ - export function readCString(buffer: NodeBuffer, offset?: number): string; + export function readCString(buffer: Buffer, offset?: number): string; /** * Read a big-endian signed 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readInt64BE(buffer: NodeBuffer, offset?: number): any; + export function readInt64BE(buffer: Buffer, offset?: number): any; /** * Read a little-endian signed 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readInt64LE(buffer: NodeBuffer, offset?: number): any; + export function readInt64LE(buffer: Buffer, offset?: number): any; /** Read a JS Object that has previously been written. */ - export function readObject(buffer: NodeBuffer, offset?: number): Object; + export function readObject(buffer: Buffer, offset?: number): Object; /** Read data from the pointer. */ - export function readPointer(buffer: NodeBuffer, offset?: number, - length?: number): NodeBuffer; + export function readPointer(buffer: Buffer, offset?: number, + length?: number): Buffer; /** * Read a big-endian unsigned 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readUInt64BE(buffer: NodeBuffer, offset?: number): any; + export function readUInt64BE(buffer: Buffer, offset?: number): any; /** * Read a little-endian unsigned 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readUInt64LE(buffer: NodeBuffer, offset?: number): any; + export function readUInt64LE(buffer: Buffer, offset?: number): any; /** Create pointer to buffer. */ - export function ref(buffer: NodeBuffer): NodeBuffer; + export function ref(buffer: Buffer): Buffer; /** Create clone of the type, with incremented indirection level by 1. */ export function refType(type: Type): Type; /** Create clone of the type, with incremented indirection level by 1. */ @@ -300,66 +300,66 @@ declare module "ref" { * This function "attaches" source to the returned buffer to prevent it from * being garbage collected. */ - export function reinterpret(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; /** * Scan past the boundary of the buffer's length until it finds size number * of aligned NULL bytes. */ - export function reinterpretUntilZeros(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: NodeBuffer, offset: number, value: any, type?: Type): void; + export function set(buffer: Buffer, offset: number, value: any, type?: Type): void; /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: NodeBuffer, offset: number, value: any, type?: string): void; + export function set(buffer: Buffer, offset: number, value: any, type?: string): void; /** Write the string as a NULL terminated. Default encoding is utf8. */ - export function writeCString(buffer: NodeBuffer, offset: number, + export function writeCString(buffer: Buffer, offset: number, string: string, encoding?: string): void; /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeInt64BE(buffer: Buffer, offset: number, input: number): void; /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeInt64BE(buffer: Buffer, offset: number, input: string): void; /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeInt64LE(buffer: Buffer, offset: number, input: number): void; /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeInt64LE(buffer: Buffer, offset: number, input: string): void; /** * Write the JS Object. This function "attaches" object to buffer to prevent * it from being garbage collected. */ - export function writeObject(buffer: NodeBuffer, offset: number, object: Object): void; + export function writeObject(buffer: Buffer, offset: number, object: Object): void; /** * Write the memory address of pointer to buffer at the specified offset. This * function "attaches" object to buffer to prevent it from being garbage collected. */ - export function writePointer(buffer: NodeBuffer, offset: number, - pointer: NodeBuffer): void; + export function writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeUInt64BE(buffer: Buffer, offset: number, input: number): void; /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeUInt64BE(buffer: Buffer, offset: number, input: string): void; /** * Attach object to buffer such. * It prevents object from being garbage collected until buffer does. */ - export function _attach(buffer: NodeBuffer, object: Object): void; + export function _attach(buffer: Buffer, object: Object): void; /** Same as ref.reinterpret, except that this version does not attach buffer. */ - export function _reinterpret(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function _reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; /** Same as ref.reinterpretUntilZeros, except that this version does not attach buffer. */ - export function _reinterpretUntilZeros(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function _reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; /** Same as ref.writePointer, except that this version does not attach pointer. */ - export function _writePointer(buffer: NodeBuffer, offset: number, - pointer: NodeBuffer): void; + export function _writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; /** Same as ref.writeObject, except that this version does not attach object. */ - export function _writeObject(buffer: NodeBuffer, offset: number, object: Object): void; + export function _writeObject(buffer: Buffer, offset: number, object: Object): void; /** Default types. */ export var types: { @@ -375,7 +375,7 @@ declare module "ref" { }; } -interface NodeBuffer { +interface Buffer { /** Shorthand for `ref.address`. */ address(): number; /** Shorthand for `ref.deref`. */ @@ -397,11 +397,11 @@ interface NodeBuffer { /** Shorthand for `ref.readUInt64LE`. */ readUInt64LE(offset?: number): string; /** Shorthand for `ref.ref`. */ - ref(): NodeBuffer; + ref(): Buffer; /** Shorthand for `ref.reinterpret`. */ - reinterpret(size: number, offset?: number): NodeBuffer; + reinterpret(size: number, offset?: number): Buffer; /** Shorthand for `ref.reinterpretUntilZeros`. */ - reinterpretUntilZeros(size: number, offset?: number): NodeBuffer; + reinterpretUntilZeros(size: number, offset?: number): Buffer; /** Shorthand for `ref.writeCString`. */ writeCString(offset: number, string: string, encoding?: string): void; /** Shorthand for `ref.writeInt64BE`. */ @@ -415,7 +415,7 @@ interface NodeBuffer { /** Shorthand for `ref.writeObject`. */ writeObject(offset: number, object: Object): void; /** Shorthand for `ref.writePointer`. */ - writePointer(offset: number, pointer: NodeBuffer): void; + writePointer(offset: number, pointer: Buffer): void; /** Shorthand for `ref.writeUInt64BE`. */ writeUInt64BE(offset: number, input: number): any; /** Shorthand for `ref.writeUInt64BE`. */ @@ -447,21 +447,21 @@ declare module "ref-array" { * for the ArrayType. The "length" of the Array is determined by searching * through the buffer's contents until an aligned NULL pointer is encountered. */ - untilZeros(buffer: NodeBuffer): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + untilZeros(buffer: Buffer): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; new (length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; new (data: number[], length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; - new (data: NodeBuffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; + new (data: Buffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; (length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; (data: number[], length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; - (data: NodeBuffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; + (data: Buffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; } /** @@ -494,10 +494,10 @@ declare module "ref-struct" { */ interface StructType extends ref.Type { /** Pass it an existing Buffer instance to use that as the backing buffer. */ - new (arg: NodeBuffer, data?: {}): any; + new (arg: Buffer, data?: {}): any; new (data?: {}): any; /** Pass it an existing Buffer instance to use that as the backing buffer. */ - (arg: NodeBuffer, data?: {}): any; + (arg: Buffer, data?: {}): any; (data?: {}): any; fields: {[key: string]: {type: ref.Type}}; @@ -551,10 +551,10 @@ declare module "ref-union" { */ interface UnionType extends ref.Type { /** Pass it an existing Buffer instance to use that as the backing buffer. */ - new (arg: NodeBuffer, data?: {}): any; + new (arg: Buffer, data?: {}): any; new (data?: {}): any; /** Pass it an existing Buffer instance to use that as the backing buffer. */ - (arg: NodeBuffer, data?: {}): any; + (arg: Buffer, data?: {}): any; (data?: {}): any; fields: {[key: string]: {type: ref.Type}}; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 39f02a53a..7a1abbae3 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -44,22 +44,22 @@ declare var module: { // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; }; declare var Buffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; } /************************************************ @@ -82,10 +82,10 @@ interface EventEmitter { interface WritableStream extends EventEmitter { writable: boolean; write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; end(): void; end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; + end(buffer: Buffer): void; destroy(): void; destroySoon(): void; } @@ -155,13 +155,13 @@ interface NodeProcess extends EventEmitter { } // Buffer class -interface NodeBuffer { +interface Buffer { [index: number]: number; write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): NodeBuffer; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; readUInt16BE(offset: number, noAssert?: boolean): number; @@ -247,7 +247,7 @@ declare module "http" { export interface ServerResponse extends events.NodeEventEmitter, stream.WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; writeContinue(): void; writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; @@ -264,7 +264,7 @@ declare module "http" { export interface ClientRequest extends events.NodeEventEmitter, stream.WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; write(chunk: any, encoding?: string): void; end(data?: any, encoding?: string): void; @@ -349,13 +349,13 @@ declare module "zlib" { export function createInflateRaw(options: ZlibOptions): InflateRaw; export function createUnzip(options: ZlibOptions): Unzip; - export function deflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function gzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function gunzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function inflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function unzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; + export function deflate(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function deflateRaw(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function gzip(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function gunzip(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function inflate(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function inflateRaw(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function unzip(buf: Buffer, callback: (error: Error, result) =>void ): void; // Constants export var Z_NO_FLUSH: number; @@ -556,8 +556,8 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; - export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function execFile(file: string, args: string[], options: { cwd?: string; stdio?: any; @@ -567,7 +567,7 @@ declare module "child_process" { timeout?: number; maxBuffer?: string; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; @@ -615,7 +615,7 @@ declare module "net" { export interface NodeSocket extends stream.ReadWriteStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; connect(port: number, host?: string, connectionListener?: Function): void; connect(path: string, connectionListener?: Function): void; @@ -668,7 +668,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; interface Socket extends events.NodeEventEmitter { - send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; address: { address: string; family: string; port: number; }; @@ -761,13 +761,13 @@ declare module "fs" { export function futimesSync(fd: string, atime: number, mtime: number): void; export function fsync(fd: string, callback?: Function): void; export function fsyncSync(fd: string): void; - export function write(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) =>any): void; - export function writeSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): void; - export function read(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; - export function readSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): any[]; + export function write(fd: string, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: Buffer) =>any): void; + export function writeSync(fd: string, buffer: Buffer, offset: number, length: number, position: number): void; + export function read(fd: string, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: string, buffer: Buffer, offset: number, length: number, position: number): any[]; export function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void ): void; - export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void; - export function readFileSync(filename: string): NodeBuffer; + export function readFile(filename: string, callback: (err: Error, data: Buffer) => void ): void; + export function readFileSync(filename: string): Buffer; export function readFileSync(filename: string, encoding: string): string; export function writeFile(filename: string, data: any, callback?: (err) => void): void; export function writeFile(filename: string, data: any, encoding?: string, callback?: (err) => void): void; @@ -811,8 +811,8 @@ declare module "path" { declare module "string_decoder" { export interface NodeStringDecoder { - write(buffer: NodeBuffer): string; - detectIncompleteChar(buffer: NodeBuffer): number; + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; } export var StringDecoder: { new (encoding: string): NodeStringDecoder; @@ -963,7 +963,7 @@ declare module "crypto" { } export function getDiffieHellman(group_name: string): DiffieHellman; export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; - export function randomBytes(size: number, callback?: (err: Error, buf: NodeBuffer) =>void ); + export function randomBytes(size: number, callback?: (err: Error, buf: Buffer) =>void ); } declare module "stream" { @@ -972,10 +972,10 @@ declare module "stream" { export interface WritableStream extends events.NodeEventEmitter { writable: boolean; write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; end(): void; end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; + end(buffer: Buffer): void; destroy(): void; destroySoon(): void; } diff --git a/node/node-tests.ts b/node/node-tests.ts index a77a4b39b..5598bac17 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -39,7 +39,7 @@ fs.writeFile("Harry Potter", assert.ifError); var content: string, - buffer: NodeBuffer; + buffer: Buffer; content = fs.readFileSync('testfile', 'utf8'); content = fs.readFileSync('testfile', {encoding : 'utf8'}); diff --git a/node/node.d.ts b/node/node.d.ts index 34862f4b7..beeb3775a 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -47,22 +47,22 @@ declare var module: { // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; }; declare var Buffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; } /************************************************ @@ -98,17 +98,17 @@ interface ReadableStream extends NodeEventEmitter { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; } interface WritableStream extends NodeEventEmitter { writable: boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -175,14 +175,16 @@ interface NodeProcess extends NodeEventEmitter { send?(message: any, sendHandle?: any): void; } -// Buffer class +/** + * @deprecated + */ interface NodeBuffer { [index: number]: number; write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): NodeBuffer; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; readUInt16BE(offset: number, noAssert?: boolean): number; @@ -214,6 +216,9 @@ interface NodeBuffer { fill(value: any, offset?: number, end?: number): void; } +// Buffer class +interface Buffer extends NodeBuffer {} + interface NodeTimer { ref() : void; unref() : void; @@ -272,8 +277,8 @@ declare module "http" { } export interface ServerResponse extends NodeEventEmitter, WritableStream { // Extended base methods - write(buffer: NodeBuffer): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -291,15 +296,15 @@ declare module "http" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; 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; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -312,7 +317,7 @@ declare module "http" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; @@ -396,13 +401,13 @@ declare module "zlib" { export function createInflateRaw(options?: ZlibOptions): InflateRaw; export function createUnzip(options?: ZlibOptions): Unzip; - export function deflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function gzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function gunzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function inflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function unzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; // Constants export var Z_NO_FLUSH: number; @@ -603,8 +608,8 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; - export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function execFile(file: string, args: string[], options: { cwd?: string; stdio?: any; @@ -614,7 +619,7 @@ declare module "child_process" { timeout?: number; maxBuffer?: string; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; @@ -676,8 +681,8 @@ declare module "net" { export interface Socket extends ReadWriteStream { // Extended base methods - write(buffer: NodeBuffer): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -701,7 +706,7 @@ declare module "net" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; @@ -739,7 +744,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; interface Socket extends NodeEventEmitter { - send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; address: { address: string; family: string; port: number; }; @@ -849,17 +854,17 @@ declare module "fs" { export function futimesSync(fd: number, atime: number, mtime: number): void; export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: NodeBuffer) => void): void; - export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: NodeBuffer) => void): void; - export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: Buffer) => void): void; + export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; export function readFile(filename: string, encoding: string, callback: (err: ErrnoException, data: string) => void): void; export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: NodeBuffer) => void): void; - export function readFile(filename: string, callback: (err: ErrnoException, data: NodeBuffer) => void ): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: ErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - export function readFileSync(filename: string, options?: { flag?: string; }): NodeBuffer; + export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; @@ -911,8 +916,8 @@ declare module "path" { declare module "string_decoder" { export interface NodeStringDecoder { - write(buffer: NodeBuffer): string; - detectIncompleteChar(buffer: NodeBuffer): number; + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; } export var StringDecoder: { new (encoding: string): NodeStringDecoder; @@ -1031,9 +1036,9 @@ declare module "crypto" { update(data: any, input_encoding?: string, output_encoding?: string): string; final(output_encoding?: string): string; setAutoPadding(auto_padding: boolean): void; + createDecipher(algorithm: string, password: any): Decipher; + createDecipheriv(algorithm: string, key: any, iv: any): Decipher; } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; interface Decipher { update(data: any, input_encoding?: string, output_encoding?: string): void; final(output_encoding?: string): string; @@ -1063,11 +1068,11 @@ declare module "crypto" { } export function getDiffieHellman(group_name: string): DiffieHellman; export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : NodeBuffer; - export function randomBytes(size: number): NodeBuffer; - export function randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; - export function pseudoRandomBytes(size: number): NodeBuffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; + export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; } declare module "stream" { @@ -1090,7 +1095,7 @@ declare module "stream" { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1103,13 +1108,13 @@ declare module "stream" { export class Writable extends events.EventEmitter implements WritableStream { writable: boolean; constructor(opts?: WritableOptions); - _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: Buffer, encoding: string, callback: Function): void; _write(data: string, encoding: string, callback: Function): void; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -1122,13 +1127,13 @@ declare module "stream" { export class Duplex extends Readable implements ReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); - _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: Buffer, encoding: string, callback: Function): void; _write(data: string, encoding: string, callback: Function): void; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -1140,7 +1145,7 @@ declare module "stream" { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); - _transform(chunk: NodeBuffer, encoding: string, callback: Function): void; + _transform(chunk: Buffer, encoding: string, callback: Function): void; _transform(chunk: string, encoding: string, callback: Function): void; _flush(callback: Function): void; read(size?: number): any; @@ -1150,14 +1155,14 @@ declare module "stream" { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } diff --git a/q-io/Q-io-tests.ts b/q-io/Q-io-tests.ts index f4ac32e9e..21b896988 100644 --- a/q-io/Q-io-tests.ts +++ b/q-io/Q-io-tests.ts @@ -8,7 +8,7 @@ var bool:boolean; var num:number; var x:any; var path:string; -var buffer:NodeBuffer; +var buffer:Buffer; var str:string; var strArr:string[]; var source:string; @@ -22,7 +22,7 @@ var anyQ:Q.Promise; var strQ:Q.Promise; var boolQ:Q.Promise; var dateQ:Q.Promise; -var bufferQ:Q.Promise; +var bufferQ:Q.Promise; var statsQ:Q.Promise; var readQ:Q.Promise; @@ -39,12 +39,12 @@ fs.open(path, options).then((x) => { }); //fs.open(path, options):Q.Promise; //fs.open(path, options):Q.Promise; -//fs.open(path, options):Q.Promise; +//fs.open(path, options):Q.Promise; //TODO how to define the multiple return types? use any for now? anyQ = fs.read(path, options); //strQ = fs.read(path, options); -//fs.read(path, options):Q.Promise; +//fs.read(path, options):Q.Promise; voidQ = fs.write(path, buffer, options); voidQ = fs.write(path, str, options); diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index cbe37214e..f9d1c10d1 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -18,17 +18,17 @@ declare module QioFS { export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; - //export function open(path:string, options?:any):Q.Promise; + //export function open(path:string, options?:any):Q.Promise; //TODO how to define the multiple return types? use any for now? export function read(path:string, options?:any):Q.Promise; //export function read(path:string, options?:any):Q.Promise; - //export function read(path:string, options?:any):Q.Promise; + //export function read(path:string, options?:any):Q.Promise; - export function write(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function write(path:string, content:Buffer, options?:any):Q.Promise; export function write(path:string, content:string, options?:any):Q.Promise; - export function append(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function append(path:string, content:Buffer, options?:any):Q.Promise; export function append(path:string, content:string, options?:any):Q.Promise; export function copy(source:string, target:string):Q.Promise; @@ -102,7 +102,7 @@ declare module QioFS { //this should return a q-io/fs-mock MockFS export function reroot(path:string):typeof QioFS; - export function toObject(path:string):{[path:string]:NodeBuffer}; + export function toObject(path:string):{[path:string]:Buffer}; //listed but not implemented by Q-io //export function glob(pattern):Q.Promise; @@ -189,7 +189,7 @@ declare module QioHTTP { declare module Qio { interface ForEachCallback { - (chunk:NodeBuffer):Q.Promise; + (chunk:Buffer):Q.Promise; (chunk:string):Q.Promise; } interface ForEach { @@ -198,13 +198,13 @@ declare module Qio { interface Reader extends ForEach { read(charset:string):Q.Promise; - read():Q.Promise; + read():Q.Promise; close():void; node:ReadableStream; } interface Writer { write(content:string):void; - write(content:NodeBuffer):void; + write(content:Buffer):void; flush():Q.Promise; close():void; destroy():void; @@ -213,9 +213,9 @@ declare module Qio { interface Stream { read(charset:string):Q.Promise; - read():Q.Promise; + read():Q.Promise; write(content:string):void; - write(content:NodeBuffer):void; + write(content:Buffer):void; flush():Q.Promise; close():void; destroy():void; @@ -229,15 +229,15 @@ declare module Qio { interface QioBufferReader { new ():Qio.Reader; read(stream:Qio.Reader, charset:string):string; - read(stream:Qio.Reader):NodeBuffer; - join(buffers:NodeBuffer[]):NodeBuffer; + read(stream:Qio.Reader):Buffer; + join(buffers:Buffer[]):Buffer; } interface QioBufferWriter { - (writer:NodeBuffer):Qio.Writer; + (writer:Buffer):Qio.Writer; Writer:Qio.Writer; } interface QioBufferStream { - (buffer:NodeBuffer, encoding:string):Qio.Stream + (buffer:Buffer, encoding:string):Qio.Stream } declare module "q-io/http" { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index 860f70ea3..f416dee81 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -43,7 +43,7 @@ declare module "superagent" { send(data: string): Request; send(data: Object): Request; write(data: string, encoding: string): boolean; - write(data: NodeBuffer, encoding: string): boolean; + write(data: Buffer, encoding: string): boolean; pipe(stream: WritableStream, options?: Object): WritableStream; buffer(val: boolean): Request; timeout(ms: number): Request; diff --git a/websocket/websocket.d.ts b/websocket/websocket.d.ts index cc22b89ea..d984e1bea 100644 --- a/websocket/websocket.d.ts +++ b/websocket/websocket.d.ts @@ -128,11 +128,11 @@ declare module "websocket" { constructor(serverConfig?: IServerConfig); /** Send binary message for each connection */ - broadcast(data: NodeBuffer): void; + broadcast(data: Buffer): void; /** Send UTF-8 message for each connection */ broadcast(data: IStringified): void; /** Send binary message for each connection */ - broadcastBytes(data: NodeBuffer): void; + broadcastBytes(data: Buffer): void; /** Send UTF-8 message for each connection */ broadcastUTF(data: IStringified): void; /** Attach the `server` instance to a Node http.Server instance */ @@ -251,26 +251,26 @@ declare module "websocket" { export interface IMessage { type: string; utf8Data?: string; - binaryData?: NodeBuffer; + binaryData?: Buffer; } export interface IBufferList extends events.EventEmitter { encoding: string; length: number; - write(buf: NodeBuffer): boolean; - end(buf: NodeBuffer): void; + write(buf: Buffer): boolean; + end(buf: Buffer): void; /** * For each buffer, perform some action. * If fn's result is a true value, cut out early. */ - forEach(fn: (buf: NodeBuffer) => boolean): void; + forEach(fn: (buf: Buffer) => boolean): void; /** Create a single buffer out of all the chunks */ - join(start: number, end: number): NodeBuffer; + join(start: number, end: number): Buffer; /** Join all the chunks to existing buffer */ - joinInto(buf: NodeBuffer, offset: number, start: number, end: number): NodeBuffer; + joinInto(buf: Buffer, offset: number, start: number, end: number): Buffer; /** * Advance the buffer stream by `n` bytes. @@ -290,10 +290,10 @@ declare module "websocket" { // Events on(event: string, listener: () => void): IBufferList; on(event: 'advance', cb: (n: number) => void): IBufferList; - on(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + on(event: 'write', cb: (buf: Buffer) => void): IBufferList; addListener(event: string, listener: () => void): IBufferList; addListener(event: 'advance', cb: (n: number) => void): IBufferList; - addListener(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + addListener(event: 'write', cb: (buf: Buffer) => void): IBufferList; } class connection extends events.EventEmitter { @@ -330,8 +330,8 @@ declare module "websocket" { config: IConfig; socket: net.Socket; maskOutgoingPackets: boolean; - maskBytes: NodeBuffer; - frameHeader: NodeBuffer; + maskBytes: Buffer; + frameHeader: Buffer; bufferList: IBufferList; currentFrame: frame; fragmentationSize: number; @@ -390,14 +390,14 @@ declare module "websocket" { * to the remote peer. If config.fragmentOutgoingMessages is true the message may be * sent as multiple fragments if it exceeds config.fragmentationThreshold bytes. */ - sendBytes(buffer: NodeBuffer): void; + sendBytes(buffer: Buffer): void; /** Auto-detect the data type and send UTF-8 or Binary message */ - send(data: NodeBuffer): void; + send(data: Buffer): void; send(data: IStringified): void; /** Sends a ping frame. Ping frames must not exceed 125 bytes in length. */ - ping(data: NodeBuffer): void; + ping(data: Buffer): void; ping(data: IStringified): void; /** @@ -408,7 +408,7 @@ declare module "websocket" { * be no need to use this method to respond to pings. * Pong frames must not exceed 125 bytes in length. */ - pong(buffer: NodeBuffer): void; + pong(buffer: Buffer): void; /** * Serializes a `frame` object into binary data and immediately sends it to @@ -494,10 +494,10 @@ declare module "websocket" { * The binary payload data. * Even text frames are sent with a Buffer providing the binary payload data. */ - binaryPayload: NodeBuffer; + binaryPayload: Buffer; - maskBytes: NodeBuffer; - frameHeader: NodeBuffer; + maskBytes: Buffer; + frameHeader: Buffer; config: IConfig; maxReceivedFrameSize: number; protocolError: boolean; @@ -507,7 +507,7 @@ declare module "websocket" { addData(bufferList: IBufferList): boolean; throwAwayPayload(bufferList: IBufferList): boolean; - toBuffer(nullMask: boolean): NodeBuffer; + toBuffer(nullMask: boolean): Buffer; } export interface IClientConfig extends IConfig { diff --git a/ws/ws.d.ts b/ws/ws.d.ts index 2a3dbae40..5e5393ea5 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -110,7 +110,7 @@ declare module "ws" { close(): void; handleUpgrade(request: http.ClientRequest, socket: net.Socket, - upgradeHead: NodeBuffer, callback: (client: WebSocket) => void): void; + upgradeHead: Buffer, callback: (client: WebSocket) => void): void; // Events on(event: string, listener: () => void): Server; From c40cc2df8905af0ede9acbeea46e7d580a2eb4ea Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 18:35:06 +0400 Subject: [PATCH 2/6] node: rename ErrnoException to NodeErrnoException --- node/node.d.ts | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index beeb3775a..6be669a01 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -71,7 +71,7 @@ declare var Buffer: { * * ************************************************/ -interface ErrnoException extends Error { +interface NodeErrnoException extends Error { errno?: any; code?: string; path?: string; @@ -789,90 +789,90 @@ declare module "fs" { export interface ReadStream extends ReadableStream { } export interface WriteStream extends WritableStream { } - export function rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void; + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: ErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: ErrnoException) => void): void; + export function truncate(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeErrnoException) => void): void; export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: ErrnoException) => void): void; + export function ftruncate(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeErrnoException) => void): void; export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function chmodSync(path: string, mode: number): void; export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: ErrnoException) => void): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function fchmodSync(fd: number, mode: number): void; export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function lchmodSync(path: string, mode: number): void; export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: ErrnoException, stats: Stats) => any): void; + export function stat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeErrnoException, stats: Stats) => any): void; export function statSync(path: string): Stats; export function lstatSync(path: string): Stats; export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: ErrnoException) => void): void; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeErrnoException) => void): void; export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: ErrnoException) => void): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeErrnoException) => void): void; export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: ErrnoException, linkString: string) => any): void; + export function readlink(path: string, callback?: (err: NodeErrnoException, linkString: string) => any): void; export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: ErrnoException, resolvedPath: string) =>any): void; + export function realpath(path: string, callback?: (err: NodeErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeErrnoException, resolvedPath: string) =>any): void; export function realpathSync(path: string, cache?: {[path: string]: string}): string; - export function unlink(path: string, callback?: (err?: ErrnoException) => void): void; + export function unlink(path: string, callback?: (err?: NodeErrnoException) => void): void; export function unlinkSync(path: string): void; - export function rmdir(path: string, callback?: (err?: ErrnoException) => void): void; + export function rmdir(path: string, callback?: (err?: NodeErrnoException) => void): void; export function rmdirSync(path: string): void; - export function mkdir(path: string, callback?: (err?: ErrnoException) => void): void; - export function mkdir(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function mkdir(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function mkdir(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: ErrnoException, files: string[]) => void): void; + export function readdir(path: string, callback?: (err: NodeErrnoException, files: string[]) => void): void; export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: ErrnoException) => void): void; + export function close(fd: number, callback?: (err?: NodeErrnoException) => void): void; export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeErrnoException, fd: number) => any): void; export function openSync(path: string, flags: string, mode?: number): number; export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; export function utimesSync(path: string, atime: number, mtime: number): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; export function futimesSync(fd: number, atime: number, mtime: number): void; - export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void; + export function fsync(fd: number, callback?: (err?: NodeErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, written: number, buffer: Buffer) => void): void; export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, bytesRead: number, buffer: Buffer) => void): void; export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function readFile(filename: string, encoding: string, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: Buffer) => void): void; - export function readFile(filename: string, callback: (err: ErrnoException, data: Buffer) => void ): void; + export function readFile(filename: string, encoding: string, callback: (err: NodeErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: NodeErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function writeFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; From d100d104c6b01549027c2beac1d742571a13d654 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 18:50:35 +0400 Subject: [PATCH 3/6] node: now modules depend on events.EventEmitter, not NodeEventEmitter --- browser-harness/browser-harness.d.ts | 33 ++++++++++++++-------------- msnodesql/msnodesql.d.ts | 4 +++- node/node.d.ts | 31 +++++++++++++------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts index 68dbf8be5..a96074164 100644 --- a/browser-harness/browser-harness.d.ts +++ b/browser-harness/browser-harness.d.ts @@ -6,27 +6,28 @@ /// declare module "browser-harness" { + import _events = require('events'); - interface HarnessEvents extends NodeEventEmitter { - once(event: string, listener: (driver: Driver) => void): NodeEventEmitter; - once(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; + interface HarnessEvents extends _events.EventEmitter { + once(event: string, listener: (driver: Driver) => void): _events.EventEmitter; + once(event: 'ready', listener: (driver: Driver) => void): _events.EventEmitter; - on(event: string, listener: (driver: Driver) => void): NodeEventEmitter; - on(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; + on(event: string, listener: (driver: Driver) => void): _events.EventEmitter; + on(event: 'ready', listener: (driver: Driver) => void): _events.EventEmitter; } - interface DriverEvents extends NodeEventEmitter { - once(event: string, listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; - once(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; + interface DriverEvents extends _events.EventEmitter { + once(event: string, listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.log', listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.warn', listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.error', listener: (text: string) => void): _events.EventEmitter; + once(event: 'window.onerror', listener: (text: string) => void): _events.EventEmitter; - on(event: string, listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; - on(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; + on(event: string, listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.log', listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.warn', listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.error', listener: (text: string) => void): _events.EventEmitter; + on(event: 'window.onerror', listener: (text: string) => void): _events.EventEmitter; } export interface Driver { diff --git a/msnodesql/msnodesql.d.ts b/msnodesql/msnodesql.d.ts index cadb323db..39bf01fb8 100644 --- a/msnodesql/msnodesql.d.ts +++ b/msnodesql/msnodesql.d.ts @@ -7,6 +7,8 @@ /// declare module "msnodesql" { + import events = require('events'); + export function open(connectionString: string, callback?: OpenCallback): Connection; export function query(connectionString: string, query: string, callback?: QueryCallback): StreamEvents; @@ -55,5 +57,5 @@ declare module "msnodesql" { close(immediately: boolean, callback?: ErrorCallback); } - interface StreamEvents extends NodeEventEmitter { } + interface StreamEvents extends events.EventEmitter {} } \ No newline at end of file diff --git a/node/node.d.ts b/node/node.d.ts index 6be669a01..8966fa18b 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -4,7 +4,7 @@ /************************************************ * * -* Node.js v0.10.1 API * +* Node.js v0.10.1 API * * * ************************************************/ @@ -256,7 +256,7 @@ declare module "http" { import net = require("net"); import stream = require("stream"); - export interface Server extends NodeEventEmitter { + export interface Server extends events.EventEmitter { listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; listen(path: string, callback?: Function): Server; listen(handle: any, listeningListener?: Function): Server; @@ -264,7 +264,7 @@ declare module "http" { address(): { port: number; family: string; address: string; }; maxHeadersCount: number; } - export interface ServerRequest extends NodeEventEmitter, ReadableStream { + export interface ServerRequest extends events.EventEmitter, ReadableStream { method: string; url: string; headers: any; @@ -275,7 +275,7 @@ declare module "http" { resume(): void; connection: net.Socket; } - export interface ServerResponse extends NodeEventEmitter, WritableStream { + export interface ServerResponse extends events.EventEmitter, WritableStream { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -301,7 +301,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientRequest extends NodeEventEmitter, WritableStream { + export interface ClientRequest extends events.EventEmitter, WritableStream { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -322,7 +322,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientResponse extends NodeEventEmitter, ReadableStream { + export interface ClientResponse extends events.EventEmitter, ReadableStream { statusCode: number; httpVersion: string; headers: any; @@ -507,8 +507,8 @@ declare module "https" { }; export interface Server extends tls.Server { } export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; + export function request(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; export var globalAgent: Agent; } @@ -540,14 +540,14 @@ declare module "repl" { ignoreUndefined?: boolean; writer?: Function; } - export function start(options: ReplOptions): NodeEventEmitter; + export function start(options: ReplOptions): events.EventEmitter; } declare module "readline" { import events = require("events"); import stream = require("stream"); - export interface ReadLine extends NodeEventEmitter { + export interface ReadLine extends events.EventEmitter { setPrompt(prompt: string, length: number): void; prompt(preserveCursor?: boolean): void; question(query: string, callback: Function): void; @@ -582,7 +582,7 @@ declare module "child_process" { import events = require("events"); import stream = require("stream"); - export interface ChildProcess extends NodeEventEmitter { + export interface ChildProcess extends events.EventEmitter { stdin: WritableStream; stdout: ReadableStream; stderr: ReadableStream; @@ -743,7 +743,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; - interface Socket extends NodeEventEmitter { + interface Socket extends events.EventEmitter { send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; @@ -758,6 +758,7 @@ declare module "dgram" { declare module "fs" { import stream = require("stream"); + import events = require("events"); interface Stats { isFile(): boolean; @@ -782,7 +783,7 @@ declare module "fs" { ctime: Date; } - interface FSWatcher extends NodeEventEmitter { + interface FSWatcher extends events.EventEmitter { close(): void; } @@ -1255,8 +1256,8 @@ declare module "domain" { export class Domain extends events.EventEmitter { run(fn: Function): void; - add(emitter: NodeEventEmitter): void; - remove(emitter: NodeEventEmitter): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; bind(cb: (err: Error, data: any) => any): any; intercept(cb: (data: any) => any): any; dispose(): void; From c52e7bdf63b7d45f0d551d2534a19a3eea250ba9 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 19:49:19 +0400 Subject: [PATCH 4/6] node: now modules depend on stream.* when possible --- browserify/browserify.d.ts | 2 +- highland/highland-tests.ts | 4 +- highland/highland.d.ts | 6 +-- node/node.d.ts | 83 +++++++++++++++++++------------------- promptly/promptly.d.ts | 5 ++- q-io/Q-io.d.ts | 4 +- superagent/superagent.d.ts | 3 +- through/through.d.ts | 4 +- 8 files changed, 57 insertions(+), 54 deletions(-) diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index e725de98c..ebed2a490 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -16,7 +16,7 @@ interface BrowserifyObject extends NodeEventEmitter { debug?: boolean; standalone?: string; insertGlobalVars?: any; - }, cb?: (err: any, src: any) => void): ReadableStream; + }, cb?: (err: any, src: any) => void): NodeReadableStream; external(file: string): BrowserifyObject; ignore(file: string): BrowserifyObject; diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index 3625b3f81..0a724a7fb 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -22,8 +22,8 @@ var strArr: string[]; var numArr: string[]; var funcArr: Function[]; -var readable: ReadableStream; -var writable: WritableStream; +var readable: NodeReadableStream; +var writable: NodeWritableStream; var emitter: NodeEventEmitter; // - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 8760a5c2d..3bec0c6eb 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -62,7 +62,7 @@ interface HighlandStatic { (xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; (xs: Highland.Stream): Highland.Stream; - (xs: ReadableStream): Highland.Stream; + (xs: NodeReadableStream): Highland.Stream; (xs: NodeEventEmitter): Highland.Stream; // moar (promise for everything?) @@ -419,8 +419,8 @@ declare module Highland { * @api public */ pipe(dest: Stream): Stream; - pipe(dest: ReadWriteStream): Stream; - pipe(dest: WritableStream): void; + pipe(dest: NodeReadWriteStream): Stream; + pipe(dest: NodeWritableStream): void; /** * Destroys a stream by unlinking it from any consumers and sources. This will diff --git a/node/node.d.ts b/node/node.d.ts index 8966fa18b..d0a67ffef 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -55,6 +55,7 @@ declare var SlowBuffer: { byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; }; + declare var Buffer: { new (str: string, encoding?: string): Buffer; new (size: number): Buffer; @@ -89,20 +90,20 @@ interface NodeEventEmitter { emit(event: string, ...args: any[]): boolean; } -interface ReadableStream extends NodeEventEmitter { +interface NodeReadableStream extends NodeEventEmitter { readable: boolean; read(size?: number): any; setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; } -interface WritableStream extends NodeEventEmitter { +interface NodeWritableStream extends NodeEventEmitter { writable: boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; @@ -113,12 +114,12 @@ interface WritableStream extends NodeEventEmitter { end(str: string, encoding?: string, cb?: Function): void; } -interface ReadWriteStream extends ReadableStream, WritableStream { } +interface NodeReadWriteStream extends NodeReadableStream, NodeWritableStream {} interface NodeProcess extends NodeEventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; + stdout: NodeWritableStream; + stderr: NodeWritableStream; + stdin: NodeReadableStream; argv: string[]; execPath: string; abort(): void; @@ -264,7 +265,7 @@ declare module "http" { address(): { port: number; family: string; address: string; }; maxHeadersCount: number; } - export interface ServerRequest extends events.EventEmitter, ReadableStream { + export interface ServerRequest extends events.EventEmitter, stream.Readable { method: string; url: string; headers: any; @@ -275,7 +276,7 @@ declare module "http" { resume(): void; connection: net.Socket; } - export interface ServerResponse extends events.EventEmitter, WritableStream { + export interface ServerResponse extends events.EventEmitter, stream.Writable { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -301,7 +302,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientRequest extends events.EventEmitter, WritableStream { + export interface ClientRequest extends events.EventEmitter, stream.Writable { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -322,7 +323,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientResponse extends events.EventEmitter, ReadableStream { + export interface ClientResponse extends events.EventEmitter, stream.Readable { statusCode: number; httpVersion: string; headers: any; @@ -385,13 +386,13 @@ declare module "zlib" { import stream = require("stream"); 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 { } - export interface Inflate extends ReadWriteStream { } - export interface DeflateRaw extends ReadWriteStream { } - export interface InflateRaw extends ReadWriteStream { } - export interface Unzip extends ReadWriteStream { } + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } export function createGzip(options?: ZlibOptions): Gzip; export function createGunzip(options?: ZlibOptions): Gunzip; @@ -531,8 +532,8 @@ declare module "repl" { export interface ReplOptions { prompt?: string; - input?: ReadableStream; - output?: WritableStream; + input?: NodeReadableStream; + output?: NodeWritableStream; terminal?: boolean; eval?: Function; useColors?: boolean; @@ -557,8 +558,8 @@ declare module "readline" { write(data: any, key?: any): void; } export interface ReadLineOptions { - input: ReadableStream; - output: WritableStream; + input: NodeReadableStream; + output: NodeWritableStream; completer?: Function; terminal?: boolean; } @@ -583,9 +584,9 @@ declare module "child_process" { import stream = require("stream"); export interface ChildProcess extends events.EventEmitter { - stdin: WritableStream; - stdout: ReadableStream; - stderr: ReadableStream; + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; pid: number; kill(signal?: string): void; send(message: any, sendHandle: any): void; @@ -679,7 +680,7 @@ declare module "dns" { declare module "net" { import stream = require("stream"); - export interface Socket extends ReadWriteStream { + export interface Socket extends stream.Duplex { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -787,8 +788,8 @@ declare module "fs" { close(): void; } - export interface ReadStream extends ReadableStream { } - export interface WriteStream extends WritableStream { } + export interface ReadStream extends stream.Readable {} + export interface WriteStream extends stream.Writable {} export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; @@ -980,7 +981,7 @@ declare module "tls" { connections: number; } - export interface ClearTextStream extends ReadWriteStream { + export interface ClearTextStream extends stream.Duplex { authorized: boolean; authorizationError: Error; getPeerCertificate(): any; @@ -1085,7 +1086,7 @@ declare module "stream" { objectMode?: boolean; } - export class Readable extends events.EventEmitter implements ReadableStream { + export class Readable extends events.EventEmitter implements NodeReadableStream { readable: boolean; constructor(opts?: ReadableOptions); _read(size: number): void; @@ -1093,11 +1094,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1106,7 +1107,7 @@ declare module "stream" { decodeStrings?: boolean; } - export class Writable extends events.EventEmitter implements WritableStream { + export class Writable extends events.EventEmitter implements NodeWritableStream { writable: boolean; constructor(opts?: WritableOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1125,7 +1126,7 @@ declare module "stream" { } // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements ReadWriteStream { + export class Duplex extends Readable implements NodeReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1142,7 +1143,7 @@ declare module "stream" { export interface TransformOptions extends ReadableOptions, WritableOptions {} // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements ReadWriteStream { + export class Transform extends events.EventEmitter implements NodeReadWriteStream { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); @@ -1153,11 +1154,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; push(chunk: any, encoding?: string): boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; diff --git a/promptly/promptly.d.ts b/promptly/promptly.d.ts index 3469ea04a..8999d1cc4 100644 --- a/promptly/promptly.d.ts +++ b/promptly/promptly.d.ts @@ -6,6 +6,7 @@ /// declare module "promptly" { + import stream = require('stream'); interface Callback { (err: Error, value: string): void; @@ -17,8 +18,8 @@ declare module "promptly" { validator?: any; retry?: boolean; silent?: boolean; - input?: ReadableStream; - output?: WritableStream; + input?: NodeReadableStream; + output?: NodeWritableStream; } export function prompt(message: string, fn?: Callback):any; diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index f9d1c10d1..cc321e24b 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -200,7 +200,7 @@ declare module Qio { read(charset:string):Q.Promise; read():Q.Promise; close():void; - node:ReadableStream; + node: NodeReadableStream; } interface Writer { write(content:string):void; @@ -208,7 +208,7 @@ declare module Qio { flush():Q.Promise; close():void; destroy():void; - node:WritableStream; + node: NodeWritableStream; } interface Stream { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index f416dee81..df0e288e9 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -6,6 +6,7 @@ /// declare module "superagent" { + import stream = require('stream'); export interface Response { text: string; body: any; @@ -44,7 +45,7 @@ declare module "superagent" { send(data: Object): Request; write(data: string, encoding: string): boolean; write(data: Buffer, encoding: string): boolean; - pipe(stream: WritableStream, options?: Object): WritableStream; + pipe(stream: NodeWritableStream, options?: Object): stream.Writable; buffer(val: boolean): Request; timeout(ms: number): Request; clearTimeout(): Request; diff --git a/through/through.d.ts b/through/through.d.ts index 8a617c424..1491085a2 100644 --- a/through/through.d.ts +++ b/through/through.d.ts @@ -6,7 +6,7 @@ /// declare module "through" { - import Stream = require("stream"); + import stream = require("stream"); function through(write?: (data) => void, end?: () => void, @@ -15,7 +15,7 @@ declare module "through" { }): through.ThroughStream; module through { - export interface ThroughStream extends ReadWriteStream { + export interface ThroughStream extends stream.Transform { autoDestroy: boolean; } } From 25a3c76b4474eb66abe42a84d19525b0237521f7 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Thu, 10 Apr 2014 21:57:58 +0400 Subject: [PATCH 5/6] node: move Node* to NodeJS module --- browserify/browserify.d.ts | 4 +- highland/highland-tests.ts | 6 +- highland/highland.d.ts | 10 +- jake/jake.d.ts | 24 +-- node/node.d.ts | 359 +++++++++++++++++++------------------ promptly/promptly.d.ts | 4 +- q-io/Q-io.d.ts | 4 +- superagent/superagent.d.ts | 2 +- 8 files changed, 211 insertions(+), 202 deletions(-) diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index ebed2a490..5326abaeb 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -5,7 +5,7 @@ /// -interface BrowserifyObject extends NodeEventEmitter { +interface BrowserifyObject extends NodeJS.EventEmitter { add(file: string): BrowserifyObject; require(file: string, opts?: { expose: string; @@ -16,7 +16,7 @@ interface BrowserifyObject extends NodeEventEmitter { debug?: boolean; standalone?: string; insertGlobalVars?: any; - }, cb?: (err: any, src: any) => void): NodeReadableStream; + }, cb?: (err: any, src: any) => void): NodeJS.ReadableStream; external(file: string): BrowserifyObject; ignore(file: string): BrowserifyObject; diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index 0a724a7fb..c7e213aa1 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -22,9 +22,9 @@ var strArr: string[]; var numArr: string[]; var funcArr: Function[]; -var readable: NodeReadableStream; -var writable: NodeWritableStream; -var emitter: NodeEventEmitter; +var readable: NodeJS.ReadableStream; +var writable: NodeJS.WritableStream; +var emitter: NodeJS.EventEmitter; // - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 3bec0c6eb..3f98c948e 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -62,8 +62,8 @@ interface HighlandStatic { (xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; (xs: Highland.Stream): Highland.Stream; - (xs: NodeReadableStream): Highland.Stream; - (xs: NodeEventEmitter): Highland.Stream; + (xs: NodeJS.ReadableStream): Highland.Stream; + (xs: NodeJS.EventEmitter): Highland.Stream; // moar (promise for everything?) (xs: Highland.Thenable>): Highland.Stream; @@ -365,7 +365,7 @@ declare module Highland { /** * Actual Stream constructor wrapped the the main exported function */ - interface Stream extends NodeEventEmitter { + interface Stream extends NodeJS.EventEmitter { /** * Pauses the stream. All Highland Streams start in the paused state. @@ -419,8 +419,8 @@ declare module Highland { * @api public */ pipe(dest: Stream): Stream; - pipe(dest: NodeReadWriteStream): Stream; - pipe(dest: NodeWritableStream): void; + pipe(dest: NodeJS.ReadWriteStream): Stream; + pipe(dest: NodeJS.WritableStream): void; /** * Destroys a stream by unlinking it from any consumers and sources. This will diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 330aac324..904a8084b 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -133,7 +133,7 @@ declare module jake{ * @event stderr When the stderr for the child-process recieves data. This streams the stderr data. Passes one arg, the chunk of data. * @event error When a shell-command */ - export interface Exec extends NodeEventEmitter { + export interface Exec extends NodeJS.EventEmitter { append(cmd:string): void; run(): void; } @@ -187,7 +187,7 @@ declare module jake{ * * @event complete */ - export class Task implements NodeEventEmitter { + export class Task implements NodeJS.EventEmitter { /** * @name name The name of the Task * @param prereqs Prerequisites to be run before this task @@ -206,11 +206,11 @@ declare module jake{ */ reenable(): void; - addListener(event: string, listener: Function): NodeEventEmitter; - on(event: string, listener: Function): NodeEventEmitter; - once(event: string, listener: Function): NodeEventEmitter; - removeListener(event: string, listener: Function): NodeEventEmitter; - removeAllListeners(event?: string): NodeEventEmitter; + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; @@ -381,11 +381,11 @@ declare module jake{ constructor(name:string, definition?:()=>void); } - export function addListener(event: string, listener: Function): NodeEventEmitter; - export function on(event: string, listener: Function): NodeEventEmitter; - export function once(event: string, listener: Function): NodeEventEmitter; - export function removeListener(event: string, listener: Function): NodeEventEmitter; - export function removeAllListener(event: string): NodeEventEmitter; + export function addListener(event: string, listener: Function): NodeJS.EventEmitter; + export function on(event: string, listener: Function): NodeJS.EventEmitter; + export function once(event: string, listener: Function): NodeJS.EventEmitter; + export function removeListener(event: string, listener: Function): NodeJS.EventEmitter; + export function removeAllListener(event: string): NodeJS.EventEmitter; export function setMaxListeners(n: number): void; export function listeners(event: string): Function[]; export function emit(event: string, ...args: any[]): boolean; diff --git a/node/node.d.ts b/node/node.d.ts index d0a67ffef..11af9e5b1 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -13,17 +13,17 @@ * GLOBAL * * * ************************************************/ -declare var process: NodeProcess; +declare var process: NodeJS.Process; declare var global: any; declare var __filename: string; declare var __dirname: string; -declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; -declare function clearTimeout(timeoutId: NodeTimer): void; -declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; -declare function clearInterval(intervalId: NodeTimer): void; -declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any; +declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearTimeout(timeoutId: NodeJS.Timer): void; +declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearInterval(intervalId: NodeJS.Timer): void; +declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; declare function clearImmediate(immediateId: any): void; declare var require: { @@ -32,7 +32,7 @@ declare var require: { cache: any; extensions: any; main: any; -} +}; declare var module: { exports: any; @@ -42,7 +42,7 @@ declare var module: { loaded: boolean; parent: any; children: any[]; -} +}; // Same as module.exports declare var exports: any; @@ -56,6 +56,9 @@ declare var SlowBuffer: { concat(list: Buffer[], totalLength?: number): Buffer; }; + +// Buffer class +interface Buffer extends NodeBuffer {} declare var Buffer: { new (str: string, encoding?: string): Buffer; new (size: number): Buffer; @@ -68,112 +71,126 @@ declare var Buffer: { /************************************************ * * -* INTERFACES * +* GLOBAL INTERFACES * * * ************************************************/ +declare module NodeJS { + export interface ErrnoException extends Error { + errno?: any; + code?: string; + path?: string; + syscall?: string; + } -interface NodeErrnoException extends Error { - errno?: any; - code?: string; - path?: string; - syscall?: string; -} + export interface EventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } -interface NodeEventEmitter { - addListener(event: string, listener: Function): NodeEventEmitter; - on(event: string, listener: Function): NodeEventEmitter; - once(event: string, listener: Function): NodeEventEmitter; - removeListener(event: string, listener: Function): NodeEventEmitter; - removeAllListeners(event?: string): NodeEventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; -} + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } -interface NodeReadableStream extends NodeEventEmitter { - readable: boolean; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; -} + export interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } -interface NodeWritableStream extends NodeEventEmitter { - writable: boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; -} + export interface ReadWriteStream extends ReadableStream, WritableStream {} -interface NodeReadWriteStream extends NodeReadableStream, NodeWritableStream {} - -interface NodeProcess extends NodeEventEmitter { - stdout: NodeWritableStream; - stderr: NodeWritableStream; - stdin: NodeReadableStream; - argv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; openssl: string; }; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + openssl: string; }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string): void; - pid: number; - title: string; - arch: string; - platform: string; - memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; - nextTick(callback: Function): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?:number[]): number[]; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?:number[]): number[]; - // Worker - send?(message: any, sendHandle?: any): void; + // Worker + send?(message: any, sendHandle?: any): void; + } + + export interface Timer { + ref() : void; + unref() : void; + } } /** @@ -217,14 +234,6 @@ interface NodeBuffer { fill(value: any, offset?: number, end?: number): void; } -// Buffer class -interface Buffer extends NodeBuffer {} - -interface NodeTimer { - ref() : void; - unref() : void; -} - /************************************************ * * * MODULES * @@ -238,7 +247,7 @@ declare module "querystring" { } declare module "events" { - export class EventEmitter implements NodeEventEmitter { + export class EventEmitter implements NodeJS.EventEmitter { static listenerCount(emitter: EventEmitter, event: string): number; addListener(event: string, listener: Function): EventEmitter; @@ -532,8 +541,8 @@ declare module "repl" { export interface ReplOptions { prompt?: string; - input?: NodeReadableStream; - output?: NodeWritableStream; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; terminal?: boolean; eval?: Function; useColors?: boolean; @@ -558,8 +567,8 @@ declare module "readline" { write(data: any, key?: any): void; } export interface ReadLineOptions { - input: NodeReadableStream; - output: NodeWritableStream; + input: NodeJS.ReadableStream; + output: NodeJS.WritableStream; completer?: Function; terminal?: boolean; } @@ -791,90 +800,90 @@ declare module "fs" { export interface ReadStream extends stream.Readable {} export interface WriteStream extends stream.Writable {} - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: NodeErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: NodeErrnoException) => void): void; + export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeErrnoException) => void): void; + export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function chmodSync(path: string, mode: number): void; export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fchmodSync(fd: number, mode: number): void; export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function lchmodSync(path: string, mode: number): void; export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; export function statSync(path: string): Stats; export function lstatSync(path: string): Stats; export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: NodeErrnoException) => void): void; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeErrnoException) => void): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: NodeErrnoException, linkString: string) => any): void; + export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: NodeErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeErrnoException, resolvedPath: string) =>any): void; + export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; export function realpathSync(path: string, cache?: {[path: string]: string}): string; - export function unlink(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function unlinkSync(path: string): void; - export function rmdir(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function rmdirSync(path: string): void; - export function mkdir(path: string, callback?: (err?: NodeErrnoException) => void): void; - export function mkdir(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function mkdir(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: NodeErrnoException, files: string[]) => void): void; + export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: NodeErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: NodeErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; export function openSync(path: string, flags: string, mode?: number): number; export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function utimesSync(path: string, atime: number, mtime: number): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function futimesSync(fd: number, atime: number, mtime: number): void; - export function fsync(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function readFile(filename: string, encoding: string, callback: (err: NodeErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeErrnoException, data: Buffer) => void): void; - export function readFile(filename: string, callback: (err: NodeErrnoException, data: Buffer) => void ): void; + export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; @@ -1086,7 +1095,7 @@ declare module "stream" { objectMode?: boolean; } - export class Readable extends events.EventEmitter implements NodeReadableStream { + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { readable: boolean; constructor(opts?: ReadableOptions); _read(size: number): void; @@ -1094,11 +1103,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1107,7 +1116,7 @@ declare module "stream" { decodeStrings?: boolean; } - export class Writable extends events.EventEmitter implements NodeWritableStream { + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { writable: boolean; constructor(opts?: WritableOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1126,7 +1135,7 @@ declare module "stream" { } // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeReadWriteStream { + export class Duplex extends Readable implements NodeJS.ReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1143,7 +1152,7 @@ declare module "stream" { export interface TransformOptions extends ReadableOptions, WritableOptions {} // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeReadWriteStream { + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); @@ -1154,11 +1163,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; push(chunk: any, encoding?: string): boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; diff --git a/promptly/promptly.d.ts b/promptly/promptly.d.ts index 8999d1cc4..beb831924 100644 --- a/promptly/promptly.d.ts +++ b/promptly/promptly.d.ts @@ -18,8 +18,8 @@ declare module "promptly" { validator?: any; retry?: boolean; silent?: boolean; - input?: NodeReadableStream; - output?: NodeWritableStream; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; } export function prompt(message: string, fn?: Callback):any; diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index cc321e24b..9c3963376 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -200,7 +200,7 @@ declare module Qio { read(charset:string):Q.Promise; read():Q.Promise; close():void; - node: NodeReadableStream; + node: NodeJS.ReadableStream; } interface Writer { write(content:string):void; @@ -208,7 +208,7 @@ declare module Qio { flush():Q.Promise; close():void; destroy():void; - node: NodeWritableStream; + node: NodeJS.WritableStream; } interface Stream { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index df0e288e9..9e6f9c4b5 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -45,7 +45,7 @@ declare module "superagent" { send(data: Object): Request; write(data: string, encoding: string): boolean; write(data: Buffer, encoding: string): boolean; - pipe(stream: NodeWritableStream, options?: Object): stream.Writable; + pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable; buffer(val: boolean): Request; timeout(ms: number): Request; clearTimeout(): Request; From e17cda940289318200654fc9ced181c85bfb25f1 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 22:00:50 +0200 Subject: [PATCH 6/6] node fix for mu2 --- mu2/mu2-tests.ts | 2 +- mu2/mu2.d.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mu2/mu2-tests.ts b/mu2/mu2-tests.ts index e8172b800..24b85ec4d 100644 --- a/mu2/mu2-tests.ts +++ b/mu2/mu2-tests.ts @@ -6,7 +6,7 @@ import stream = require('stream'); var str: string; var value: any; -var read: ReadableStream; +var read: NodeJS.ReadableStream; var parsed: mu2.IParsed; str = mu2.root; diff --git a/mu2/mu2.d.ts b/mu2/mu2.d.ts index cbc46d6fb..714703934 100644 --- a/mu2/mu2.d.ts +++ b/mu2/mu2.d.ts @@ -10,7 +10,7 @@ declare module "mu2" { export var root: string; - export function compileAndRender(templateName: string, view: any): ReadableStream; + export function compileAndRender(templateName: string, view: any): NodeJS.ReadableStream; export function compile(filename: string, callback: (err: Error, parsed: IParsed) => void): void; @@ -18,10 +18,10 @@ declare module "mu2" { export function compileText(name: string, template: string): IParsed; export function compileText(template: string): IParsed; - export function render(filenameOrParsed: string, view: any): ReadableStream; - export function render(filenameOrParsed: IParsed, view: any): ReadableStream; + export function render(filenameOrParsed: string, view: any): NodeJS.ReadableStream; + export function render(filenameOrParsed: IParsed, view: any): NodeJS.ReadableStream; - export function renderText(template: string, view: any, partials?: any): ReadableStream; + export function renderText(template: string, view: any, partials?: any): NodeJS.ReadableStream; export function clearCache(templateName?: string): void;