node: NodeBuffer -> Buffer. Mark NodeBuffer as deprecated

This commit is contained in:
Paul Loyd
2014-04-28 18:32:36 +02:00
committed by Bart van der Schoor
parent bcd40a14f0
commit 1d451a05e1
14 changed files with 251 additions and 246 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
import bufferEqual = require('buffer-equal');
var bool: boolean;
var buf: NodeBuffer;
var buf: Buffer;
bool = bufferEqual(buf, buf);
+1 -1
View File
@@ -6,6 +6,6 @@
/// <reference path="../node/node.d.ts" />
declare module 'buffer-equal' {
function bufferEqual(actual:NodeBuffer, expected:NodeBuffer): boolean;
function bufferEqual(actual:Buffer, expected:Buffer): boolean;
export = bufferEqual;
}
+4 -4
View File
@@ -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;
+1 -1
View File
@@ -3,6 +3,6 @@
import fs = require('graceful-fs');
var str: string;
var buf: NodeBuffer;
var buf: Buffer;
fs.renameSync(str, str);
+5 -5
View File
@@ -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.
+90 -90
View File
@@ -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}};
+40 -40
View File
@@ -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;
}
+1 -1
View File
@@ -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'});
+68 -63
View File
@@ -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<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(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<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(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<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(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;
}
+4 -4
View File
@@ -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<any>;
var strQ:Q.Promise<string>;
var boolQ:Q.Promise<boolean>;
var dateQ:Q.Promise<Date>;
var bufferQ:Q.Promise<NodeBuffer>;
var bufferQ:Q.Promise<Buffer>;
var statsQ:Q.Promise<QioFS.Stats>;
var readQ:Q.Promise<Qio.Reader>;
@@ -39,12 +39,12 @@ fs.open(path, options).then((x) => {
});
//fs.open(path, options):Q.Promise<Qio.Reader>;
//fs.open(path, options):Q.Promise<Qio.Writer>;
//fs.open(path, options):Q.Promise<NodeBuffer>;
//fs.open(path, options):Q.Promise<Buffer>;
//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<NodeBuffer>;
//fs.read(path, options):Q.Promise<Buffer>;
voidQ = fs.write(path, buffer, options);
voidQ = fs.write(path, str, options);
+14 -14
View File
@@ -18,17 +18,17 @@ declare module QioFS {
export function open(path:string, options?:any):Q.Promise<any>;
//export function open(path:string, options?:any):Q.Promise<Qio.Reader>;
//export function open(path:string, options?:any):Q.Promise<Qio.Writer>;
//export function open(path:string, options?:any):Q.Promise<NodeBuffer>;
//export function open(path:string, options?:any):Q.Promise<Buffer>;
//TODO how to define the multiple return types? use any for now?
export function read(path:string, options?:any):Q.Promise<any>;
//export function read(path:string, options?:any):Q.Promise<string>;
//export function read(path:string, options?:any):Q.Promise<NodeBuffer>;
//export function read(path:string, options?:any):Q.Promise<Buffer>;
export function write(path:string, content:NodeBuffer, options?:any):Q.Promise<void>;
export function write(path:string, content:Buffer, options?:any):Q.Promise<void>;
export function write(path:string, content:string, options?:any):Q.Promise<void>;
export function append(path:string, content:NodeBuffer, options?:any):Q.Promise<void>;
export function append(path:string, content:Buffer, options?:any):Q.Promise<void>;
export function append(path:string, content:string, options?:any):Q.Promise<void>;
export function copy(source:string, target:string):Q.Promise<void>;
@@ -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<string[]>;
@@ -189,7 +189,7 @@ declare module QioHTTP {
declare module Qio {
interface ForEachCallback {
(chunk:NodeBuffer):Q.Promise<any>;
(chunk:Buffer):Q.Promise<any>;
(chunk:string):Q.Promise<any>;
}
interface ForEach {
@@ -198,13 +198,13 @@ declare module Qio {
interface Reader extends ForEach {
read(charset:string):Q.Promise<string>;
read():Q.Promise<NodeBuffer>;
read():Q.Promise<Buffer>;
close():void;
node:ReadableStream;
}
interface Writer {
write(content:string):void;
write(content:NodeBuffer):void;
write(content:Buffer):void;
flush():Q.Promise<void>;
close():void;
destroy():void;
@@ -213,9 +213,9 @@ declare module Qio {
interface Stream {
read(charset:string):Q.Promise<string>;
read():Q.Promise<NodeBuffer>;
read():Q.Promise<Buffer>;
write(content:string):void;
write(content:NodeBuffer):void;
write(content:Buffer):void;
flush():Q.Promise<void>;
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" {
+1 -1
View File
@@ -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;
+20 -20
View File
@@ -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 {
Vendored
+1 -1
View File
@@ -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;