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
+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;
}