Skip to content

Commit d82e7f7

Browse files
committed
More heavy refactoring, include util module
Closes #13
1 parent 0ea224f commit d82e7f7

File tree

4 files changed

+1146
-156
lines changed

4 files changed

+1146
-156
lines changed

0.10/node.d.ts

Lines changed: 187 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ declare namespace NodeJS {
274274
[key: string]: string;
275275
}
276276

277+
export interface Versions {
278+
http_parser: string;
279+
node: string;
280+
v8: string;
281+
ares: string;
282+
uv: string;
283+
zlib: string;
284+
modules: string;
285+
openssl: string;
286+
}
287+
277288
export interface Process extends EventEmitter {
278289
stdout: WritableStream;
279290
stderr: WritableStream;
@@ -296,16 +307,7 @@ declare namespace NodeJS {
296307
setuid(id: number): void;
297308
setuid(id: string): void;
298309
version: string;
299-
versions: {
300-
http_parser: string;
301-
node: string;
302-
v8: string;
303-
ares: string;
304-
uv: string;
305-
zlib: string;
306-
modules: string;
307-
openssl: string;
308-
};
310+
versions: Versions;
309311
config: {
310312
target_defaults: {
311313
cflags: any[];
@@ -350,6 +352,15 @@ declare namespace NodeJS {
350352
export interface Timer {
351353
ref(): void;
352354
unref(): void;
355+
_called: boolean;
356+
_onTimeout: Function;
357+
_timerArgs?: any[];
358+
}
359+
360+
export interface Immediate {
361+
_argv?: any[];
362+
_callback: Function;
363+
_onImmediate: Function;
353364
}
354365
}
355366

@@ -428,6 +439,7 @@ declare module "http" {
428439
trailers: IncomingHeaders;
429440
rawTrailers: string[];
430441
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
442+
destroy(error?: Error): void;
431443
/**
432444
* Only valid for request obtained from http.Server.
433445
*/
@@ -448,6 +460,11 @@ declare module "http" {
448460
}
449461

450462
export class ServerResponse extends stream.Writable {
463+
finished: boolean;
464+
headersSent: boolean;
465+
statusCode: number;
466+
sendDate: boolean;
467+
451468
// Extended base methods
452469
write(buffer: Buffer): boolean;
453470
write(buffer: Buffer, cb?: Function): boolean;
@@ -458,10 +475,8 @@ declare module "http" {
458475
writeContinue(): void;
459476
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
460477
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
461-
statusCode: number;
462478
setHeader(name: string, value: string): void;
463479
setTimeout(msecs: number, callback: () => void): this;
464-
sendDate: boolean;
465480
getHeader(name: string): string;
466481
removeHeader(name: string): void;
467482
write(chunk: any, encoding?: string): any;
@@ -594,7 +609,7 @@ declare module "cluster" {
594609
id: string;
595610
process: child.ChildProcess;
596611
suicide: boolean;
597-
send(message: any, sendHandle?: any): void;
612+
send(message: any, sendHandle?: any): boolean;
598613
kill(signal?: string): void;
599614
destroy(signal?: string): void;
600615
disconnect(): void;
@@ -730,6 +745,42 @@ declare module "https" {
730745
}
731746

732747
export interface AgentOptions extends http.AgentOptions {
748+
/**
749+
* Certificate, Private key and CA certificates to use for SSL. Default `null`.
750+
*/
751+
pfx?: string | Buffer;
752+
/**
753+
* Private key to use for SSL. Default `null`.
754+
*/
755+
key?: string | Buffer | string[] | Buffer[];
756+
/**
757+
* A string of passphrase for the private key or pfx. Default `null`.
758+
*/
759+
passphrase?: string;
760+
/**
761+
* Public x509 certificate to use. Default `null`.
762+
*/
763+
cert?: string | Buffer | string[] | Buffer[];
764+
/**
765+
* A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections.
766+
*/
767+
ca?: string | Buffer | string[] | Buffer[];
768+
/**
769+
* A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format.
770+
*/
771+
ciphers?: string;
772+
/**
773+
* If `true`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default `true`.
774+
*/
775+
rejectUnauthorized?: boolean;
776+
/**
777+
* Servername for SNI (Server Name Indication) TLS extension.
778+
*/
779+
servername?: string;
780+
/**
781+
* The SSL method to use, e.g. `SSLv3_method` to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS.
782+
*/
783+
secureProtocol?: string;
733784
maxCachedSessions?: number;
734785
}
735786

@@ -862,7 +913,7 @@ declare module "child_process" {
862913
stdio: [stream.Writable, stream.Readable, stream.Readable];
863914
pid: number;
864915
kill(signal?: string): void;
865-
send(message: any, sendHandle?: any): void;
916+
send(message: any, sendHandle?: any): boolean;
866917
connected: boolean;
867918
disconnect(): void;
868919
unref(): void;
@@ -2127,25 +2178,121 @@ declare module "stream" {
21272178

21282179
declare module "util" {
21292180
export interface InspectOptions {
2181+
/**
2182+
* If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`.
2183+
*/
21302184
showHidden?: boolean;
2185+
/**
2186+
* Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`.
2187+
*/
21312188
depth?: number | null;
2189+
/**
2190+
* If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see "Customizing util.inspect colors".
2191+
*/
21322192
colors?: boolean;
2193+
/**
2194+
* If `false`, then custom `inspect(depth, opts)` functions exported on the object being inspected will not be called. Defaults to `true`.
2195+
*/
21332196
customInspect?: boolean;
21342197
}
21352198

2136-
export function format(format: any, ...param: any[]): string;
2137-
export function debug(string: string): void;
2138-
export function error(...param: any[]): void;
2139-
export function puts(...param: any[]): void;
2140-
export function print(...param: any[]): void;
2141-
export function log(string: string): void;
2199+
/**
2200+
* The `util.inspect()` method returns a string representation of object that is primarily useful for debugging.
2201+
*/
21422202
export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
21432203
export function inspect(object: any, options: InspectOptions): string;
2144-
export function isArray(object: any): boolean;
2145-
export function isRegExp(object: any): boolean;
2146-
export function isDate(object: any): boolean;
2147-
export function isError(object: any): boolean;
2204+
2205+
export namespace inspect {
2206+
export var colors: {
2207+
bold: [number, number];
2208+
italic: [number, number];
2209+
underline: [number, number];
2210+
inverse: [number, number];
2211+
white: [number, number];
2212+
grey: [number, number];
2213+
black: [number, number];
2214+
blue: [number, number];
2215+
cyan: [number, number];
2216+
green: [number, number];
2217+
magenta: [number, number];
2218+
red: [number, number];
2219+
yellow: [number, number];
2220+
}
2221+
2222+
export var styles: {
2223+
special: string;
2224+
number: string;
2225+
boolean: string;
2226+
undefined: string;
2227+
null: string;
2228+
string: string;
2229+
symbol: string;
2230+
date: string;
2231+
regexp: string;
2232+
};
2233+
}
2234+
2235+
/**
2236+
* The `util.format()` method returns a formatted string using the first argument as a printf-like format.
2237+
*/
2238+
export function format(format: any, ...param: any[]): string;
2239+
2240+
/**
2241+
* Inherit the prototype methods from one constructor into another. The prototype of constructor will be set to a new object created from superConstructor.
2242+
*/
21482243
export function inherits(constructor: any, superConstructor: any): void;
2244+
2245+
/**
2246+
* Predecessor of `console.error`.
2247+
*/
2248+
export function debug(string: string): void;
2249+
2250+
/**
2251+
* Predecessor of `console.error`.
2252+
*/
2253+
export function error(...strings: string[]): void;
2254+
2255+
/**
2256+
* Internal alias for `Array.isArray`.
2257+
*/
2258+
export function isArray(object: any): object is any[];
2259+
2260+
/**
2261+
* Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
2262+
*/
2263+
export function isDate(object: any): object is Date;
2264+
2265+
/**
2266+
* Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
2267+
*/
2268+
export function isError(object: any): object is Error;
2269+
2270+
/**
2271+
* Returns true if the given `object` is a `RegExp`. Otherwise, returns `false`.
2272+
*/
2273+
export function isRegExp(object: any): object is RegExp;
2274+
2275+
/**
2276+
* The `util.log()` method prints the given `string` to `stdout` with an included timestamp.
2277+
*/
2278+
export function log(string: string): void;
2279+
2280+
/**
2281+
* Predecessor of `console.log`.
2282+
*/
2283+
export function print(strings: string[]): void;
2284+
2285+
/**
2286+
* Predecessor of `console.log`.
2287+
*/
2288+
export function puts(strings: string[]): void;
2289+
2290+
/**
2291+
* The `util._extend()` method was never intended to be used outside of internal Node.js modules. The community found and used it anyway.
2292+
*
2293+
* It is deprecated and should not be used in new code. JavaScript comes with very similar built-in functionality through `Object.assign()`.
2294+
*/
2295+
export function _extend<T, U>(target: T, source: U): T & U;
21492296
}
21502297

21512298
declare module "assert" {
@@ -2217,6 +2364,9 @@ declare module "domain" {
22172364
bind(cb: (err: Error, data: any) => any): any;
22182365
intercept(cb: (data: any) => any): any;
22192366
dispose(): void;
2367+
members: any[];
2368+
enter(): void;
2369+
exit(): void;
22202370
}
22212371

22222372
export function create(): Domain;
@@ -2225,3 +2375,16 @@ declare module "domain" {
22252375
declare module "module" {
22262376
export = NodeModule;
22272377
}
2378+
2379+
declare module "process" {
2380+
export = process;
2381+
}
2382+
2383+
declare module "timers" {
2384+
export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
2385+
export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
2386+
export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
2387+
export function clearTimeout(timeoutId: NodeJS.Timer): void;
2388+
export function clearInterval(intervalId: NodeJS.Timer): void;
2389+
export function clearImmediate(immediateId: NodeJS.Immediate): void;
2390+
}

0 commit comments

Comments
 (0)