Merge pull request #2118 from Bartvds/node-2/full

Move global node interfaces to NodeJS module, drop Node prefixes, close #2020
This commit is contained in:
Bart van der Schoor
2014-04-28 22:26:41 +02:00
24 changed files with 512 additions and 491 deletions
+17 -16
View File
@@ -6,27 +6,28 @@
/// <reference path="../node/node.d.ts" />
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 {
+2 -2
View File
@@ -5,7 +5,7 @@
/// <reference path="../node/node.d.ts" />
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): ReadableStream;
}, cb?: (err: any, src: any) => void): NodeJS.ReadableStream;
external(file: string): BrowserifyObject;
ignore(file: string): BrowserifyObject;
+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.
+3 -3
View File
@@ -22,9 +22,9 @@ var strArr: string[];
var numArr: string[];
var funcArr: Function[];
var readable: ReadableStream;
var writable: WritableStream;
var emitter: NodeEventEmitter;
var readable: NodeJS.ReadableStream;
var writable: NodeJS.WritableStream;
var emitter: NodeJS.EventEmitter;
// - - - - - - - - - - - - - - - - -
+5 -5
View File
@@ -62,8 +62,8 @@ interface HighlandStatic {
<R>(xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream<R>;
<R>(xs: Highland.Stream<R>): Highland.Stream<R>;
<R>(xs: ReadableStream): Highland.Stream<R>;
<R>(xs: NodeEventEmitter): Highland.Stream<R>;
<R>(xs: NodeJS.ReadableStream): Highland.Stream<R>;
<R>(xs: NodeJS.EventEmitter): Highland.Stream<R>;
// moar (promise for everything?)
<R>(xs: Highland.Thenable<Highland.Stream<R>>): Highland.Stream<R>;
@@ -365,7 +365,7 @@ declare module Highland {
/**
* Actual Stream constructor wrapped the the main exported function
*/
interface Stream<R> extends NodeEventEmitter {
interface Stream<R> extends NodeJS.EventEmitter {
/**
* Pauses the stream. All Highland Streams start in the paused state.
@@ -419,8 +419,8 @@ declare module Highland {
* @api public
*/
pipe<U>(dest: Stream<U>): Stream<U>;
pipe<U>(dest: ReadWriteStream): Stream<U>;
pipe(dest: WritableStream): void;
pipe<U>(dest: NodeJS.ReadWriteStream): Stream<U>;
pipe(dest: NodeJS.WritableStream): void;
/**
* Destroys a stream by unlinking it from any consumers and sources. This will
+12 -12
View File
@@ -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;
+3 -1
View File
@@ -7,6 +7,8 @@
///<reference path='../node/node.d.ts' />
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 {}
}
+1 -1
View File
@@ -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;
+4 -4
View File
@@ -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;
+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'});
+273 -257
View File
@@ -4,7 +4,7 @@
/************************************************
* *
* Node.js v0.10.1 API *
* Node.js v0.10.1 API *
* *
************************************************/
@@ -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,147 +42,167 @@ declare var module: {
loaded: boolean;
parent: any;
children: any[];
}
};
// 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;
};
// Buffer class
interface Buffer extends NodeBuffer {}
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;
}
/************************************************
* *
* INTERFACES *
* GLOBAL INTERFACES *
* *
************************************************/
declare module NodeJS {
export interface ErrnoException extends Error {
errno?: any;
code?: string;
path?: string;
syscall?: string;
}
interface ErrnoException 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<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
wrap(oldStream: ReadableStream): ReadableStream;
}
interface ReadableStream extends NodeEventEmitter {
readable: boolean;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
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;
wrap(oldStream: ReadableStream): ReadableStream;
}
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 WritableStream extends NodeEventEmitter {
writable: boolean;
write(buffer: NodeBuffer, 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(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export interface ReadWriteStream extends ReadableStream, WritableStream {}
interface ReadWriteStream extends ReadableStream, WritableStream { }
interface NodeProcess extends NodeEventEmitter {
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; };
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;
}
}
// 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,11 +234,6 @@ interface NodeBuffer {
fill(value: any, offset?: number, end?: number): void;
}
interface NodeTimer {
ref() : void;
unref() : void;
}
/************************************************
* *
* MODULES *
@@ -232,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;
@@ -251,7 +266,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;
@@ -259,7 +274,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, stream.Readable {
method: string;
url: string;
headers: any;
@@ -270,10 +285,10 @@ declare module "http" {
resume(): void;
connection: net.Socket;
}
export interface ServerResponse extends NodeEventEmitter, WritableStream {
export interface ServerResponse extends events.EventEmitter, stream.Writable {
// 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 +306,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 {
export interface ClientRequest extends events.EventEmitter, stream.Writable {
// 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,12 +327,12 @@ 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 ClientResponse extends NodeEventEmitter, ReadableStream {
export interface ClientResponse extends events.EventEmitter, stream.Readable {
statusCode: number;
httpVersion: string;
headers: any;
@@ -380,13 +395,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;
@@ -396,13 +411,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;
@@ -502,8 +517,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;
}
@@ -526,8 +541,8 @@ declare module "repl" {
export interface ReplOptions {
prompt?: string;
input?: ReadableStream;
output?: WritableStream;
input?: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
terminal?: boolean;
eval?: Function;
useColors?: boolean;
@@ -535,14 +550,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;
@@ -552,8 +567,8 @@ declare module "readline" {
write(data: any, key?: any): void;
}
export interface ReadLineOptions {
input: ReadableStream;
output: WritableStream;
input: NodeJS.ReadableStream;
output: NodeJS.WritableStream;
completer?: Function;
terminal?: boolean;
}
@@ -577,10 +592,10 @@ declare module "child_process" {
import events = require("events");
import stream = require("stream");
export interface ChildProcess extends NodeEventEmitter {
stdin: WritableStream;
stdout: ReadableStream;
stderr: ReadableStream;
export interface ChildProcess extends events.EventEmitter {
stdin: stream.Writable;
stdout: stream.Readable;
stderr: stream.Readable;
pid: number;
kill(signal?: string): void;
send(message: any, sendHandle: any): void;
@@ -603,8 +618,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 +629,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;
@@ -674,10 +689,10 @@ 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: 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 +716,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;
@@ -738,8 +753,8 @@ 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;
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;
address: { address: string; family: string; port: number; };
@@ -753,6 +768,7 @@ declare module "dgram" {
declare module "fs" {
import stream = require("stream");
import events = require("events");
interface Stats {
isFile(): boolean;
@@ -777,97 +793,97 @@ declare module "fs" {
ctime: Date;
}
interface FSWatcher extends NodeEventEmitter {
interface FSWatcher extends events.EventEmitter {
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?: ErrnoException) => 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?: ErrnoException) => void): void;
export function truncate(path: string, len: number, callback?: (err?: ErrnoException) => 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?: ErrnoException) => void): void;
export function ftruncate(fd: number, len: number, callback?: (err?: ErrnoException) => 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?: ErrnoException) => 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?: ErrnoException) => 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?: ErrnoException) => 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?: ErrnoException) => void): void;
export function chmod(path: string, mode: string, callback?: (err?: ErrnoException) => 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?: ErrnoException) => void): void;
export function fchmod(fd: number, mode: string, callback?: (err?: ErrnoException) => 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?: ErrnoException) => void): void;
export function lchmod(path: string, mode: string, callback?: (err?: ErrnoException) => 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: 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: 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?: ErrnoException) => 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?: ErrnoException) => 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: ErrnoException, 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: 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: 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?: ErrnoException) => 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?: ErrnoException) => 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?: 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?: 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: ErrnoException, 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?: ErrnoException) => 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: 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: 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?: ErrnoException) => 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?: ErrnoException) => 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?: ErrnoException) => 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: 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 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 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: 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: 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; }): NodeBuffer;
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 readFileSync(filename: string, options?: { flag?: string; }): Buffer;
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: 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: 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;
@@ -911,8 +927,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;
@@ -974,7 +990,7 @@ declare module "tls" {
connections: number;
}
export interface ClearTextStream extends ReadWriteStream {
export interface ClearTextStream extends stream.Duplex {
authorized: boolean;
authorizationError: Error;
getPeerCertificate(): any;
@@ -1031,9 +1047,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 +1079,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" {
@@ -1079,7 +1095,7 @@ declare module "stream" {
objectMode?: boolean;
}
export class Readable extends events.EventEmitter implements ReadableStream {
export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
readable: boolean;
constructor(opts?: ReadableOptions);
_read(size: number): void;
@@ -1087,11 +1103,11 @@ declare module "stream" {
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(destination?: T): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: NodeBuffer): void;
wrap(oldStream: ReadableStream): ReadableStream;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
}
@@ -1100,16 +1116,16 @@ declare module "stream" {
decodeStrings?: boolean;
}
export class Writable extends events.EventEmitter implements WritableStream {
export class Writable extends events.EventEmitter implements NodeJS.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;
}
@@ -1119,16 +1135,16 @@ declare module "stream" {
}
// Note: Duplex extends both Readable and Writable.
export class Duplex extends Readable implements ReadWriteStream {
export class Duplex extends Readable implements NodeJS.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;
}
@@ -1136,28 +1152,28 @@ 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 NodeJS.ReadWriteStream {
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;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(destination?: T): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: NodeBuffer): void;
wrap(oldStream: ReadableStream): ReadableStream;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.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;
}
@@ -1250,8 +1266,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;
+3 -2
View File
@@ -6,6 +6,7 @@
///<reference path="../node/node.d.ts"/>
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?: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
}
export function prompt(message: string, fn?: Callback):any;
+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);
+16 -16
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,24 +198,24 @@ 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;
node: NodeJS.ReadableStream;
}
interface Writer {
write(content:string):void;
write(content:NodeBuffer):void;
write(content:Buffer):void;
flush():Q.Promise<void>;
close():void;
destroy():void;
node:WritableStream;
node: NodeJS.WritableStream;
}
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" {
+3 -2
View File
@@ -6,6 +6,7 @@
/// <reference path='../node/node.d.ts' />
declare module "superagent" {
import stream = require('stream');
export interface Response {
text: string;
body: any;
@@ -43,8 +44,8 @@ declare module "superagent" {
send(data: string): Request;
send(data: Object): Request;
write(data: string, encoding: string): boolean;
write(data: NodeBuffer, encoding: string): boolean;
pipe(stream: WritableStream, options?: Object): WritableStream;
write(data: Buffer, encoding: string): boolean;
pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable;
buffer(val: boolean): Request;
timeout(ms: number): Request;
clearTimeout(): Request;
+2 -2
View File
@@ -6,7 +6,7 @@
/// <reference path="../node/node.d.ts" />
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;
}
}
+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;