updated tests

This commit is contained in:
Philipp Kunz 2016-02-02 16:49:16 +01:00
parent 88e91bfc29
commit ed1b6a9a65
17 changed files with 2772 additions and 180 deletions

View File

@ -1,8 +1,6 @@
language: node_js
node_js:
- 4.2.3
before_install:
- npm install -g tsd
- 4.2.4
deploy:
provider: npm
email: npm@lossless.digital

2
index.d.ts vendored
View File

@ -1,4 +1,4 @@
/// <reference path="ts/typings/tsd.d.ts" />
/// <reference path="ts/typings/main.d.ts" />
declare module BeautylogPlugins {
var init: () => any;
}

View File

@ -244,7 +244,7 @@ var BeautylogBrowser;
}
BeautylogBrowser.init = init;
})(BeautylogBrowser || (BeautylogBrowser = {}));
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./typings/main.d.ts" />
/// <reference path="./beautylog.plugins.ts" />
/// <reference path="./beautylog.classes.ts" />
/// <reference path="./beautylog.node.ts" />

View File

@ -4,7 +4,7 @@
"description": "beautiful logging",
"main": "index.js",
"scripts": {
"test": "(npmts) && (node ./test.js)",
"test": "(npmts)",
"testbrowser": "(npm test) && (node testbrowser.js)",
"gitsetup": "(git config push.followTags true)",
"push": "(git push origin master && git push origin release && git push --follow-tags)",

71
test/test.js Normal file
View File

@ -0,0 +1,71 @@
/// <reference path="./typings/main.d.ts" />
var smartenv = require("smartenv");
var beautylog = require('../index.js');
describe("beautylog", function () {
describe(".log(message,logtype)", function () {
it("should log cyan text", function () {
beautylog.log('beautylog.log(), with normal logText, without logType');
});
it("should print different log types dependent on logType", function () {
beautylog.log('beautylog.log(), with normal logText, without logType');
beautylog.log('beautylog.log(), with normal logText, with logType "dir"', 'dir');
beautylog.log('beautylog.log(), with normal logText, with logType "error"', 'error');
beautylog.log('beautylog.log(), with normal logText, with logType "info"', 'info');
beautylog.log('beautylog.log(), with normal logText, with logType "ok"', 'ok');
beautylog.log('beautylog.log(), with normal logText, with logType "success"', 'success');
beautylog.log('beautylog.log(), with normal logText, with logType "warn"', 'warn');
});
});
describe(".dir(message)", function () {
it("should print a blue Dir message", function () {
beautylog.dir('beautylog.dir(), with normal logText, without logType');
});
});
describe(".error(message)", function () {
it("sould print a red error message", function () {
beautylog.error('beautylog.error(), with normal logText, without logType');
});
});
describe(".info(message)", function () {
it("should display a purple info message", function () {
beautylog.info('beautylog.dir(), with normal logText, without logType');
});
});
describe(".ok(message)", function () {
it("should display a green ok message", function () {
beautylog.ok('beautylog.ok(), with normal logText, without logType');
});
});
describe(".success(message)", function () {
it("should display an orange warn message", function () {
beautylog.success('beautylog.success(), with normal logText, without logType');
});
});
describe(".warn", function () {
it("should display a orange warn message", function () {
beautylog.warn('beautylog.warn(), with normal logText, without logType');
});
});
describe(".table", function () {
it("should print a nice table", function () {
(function () {
var testTable1 = beautylog.table.new("checks");
testTable1.push(['check1', 'success']);
testTable1.push(['check2', 'error']);
testTable1.push(['check3', 'error']);
testTable1.print();
var testTable2 = beautylog.table.new("custom", ["Column1".red, "Column2".blue, "Column3".cyan]);
testTable2.push(["Hey", "this", "works"]);
testTable2.print();
})();
});
});
describe(".code", function () {
it("should highlight code", function () {
this.timeout(10000);
beautylog.code("var test = 3;\nfunction(){\n var hello = \"super\"\n};\nvar test;", {
language: "javascript"
});
});
});
});

View File

@ -1,4 +1,4 @@
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./typings/main.d.ts" />
/// <reference path="./beautylog.plugins.ts" />
/// <reference path="./beautylog.classes.ts" />
/// <reference path="./beautylog.node.ts" />

View File

@ -1,54 +1,78 @@
/// <reference path="./typings/tsd.d.ts" />
/// <reference path="./typings/main.d.ts" />
var smartenv = require("smartenv");
var beautyLog = require('./index.js');
var beautylog = require('../index.js');
console.log('*** start OS console test ***');
console.log ('');
describe("beautylog",function(){
describe(".log(message,logtype)",function(){
it("should log cyan text",function(){
beautylog.log('beautylog.log(), with normal logText, without logType');
});
it("should print different log types dependent on logType",function(){
beautylog.log('beautylog.log(), with normal logText, without logType');
beautylog.log('beautylog.log(), with normal logText, with logType "dir"','dir');
beautylog.log('beautylog.log(), with normal logText, with logType "error"','error');
beautylog.log('beautylog.log(), with normal logText, with logType "info"','info');
beautylog.log('beautylog.log(), with normal logText, with logType "ok"','ok');
beautylog.log('beautylog.log(), with normal logText, with logType "success"','success');
beautylog.log('beautylog.log(), with normal logText, with logType "warn"','warn');
});
});
describe(".dir(message)",function(){
it("should print a blue Dir message",function(){
beautylog.dir('beautylog.dir(), with normal logText, without logType');
})
})
describe(".error(message)",function(){
it("sould print a red error message",function(){
beautylog.error('beautylog.error(), with normal logText, without logType');
});
});
describe(".info(message)",function(){
it("should display a purple info message",function(){
beautylog.info('beautylog.dir(), with normal logText, without logType');
});
});
describe(".ok(message)",function(){
it("should display a green ok message",function(){
beautylog.ok('beautylog.ok(), with normal logText, without logType');
});
});
describe(".success(message)",function(){
it("should display an orange warn message",function(){
beautylog.success('beautylog.success(), with normal logText, without logType');
})
});
describe(".warn",function(){
it("should display a orange warn message",function(){
beautylog.warn('beautylog.warn(), with normal logText, without logType');
});
});
describe(".table",function(){
it("should print a nice table",function(){
(function(){
var testTable1 = beautylog.table.new("checks");
testTable1.push(['check1','success']);
testTable1.push(['check2','error']);
testTable1.push(['check3','error']);
testTable1.print();
console.log('declarative function calls:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.dir('beautylog.dir(), with normal logText, without logType');
beautyLog.error('beautylog.error(), with normal logText, without logType');
beautyLog.info('beautylog.dir(), with normal logText, without logType');
beautyLog.ok('beautylog.ok(), with normal logText, without logType');
beautyLog.success('beautylog.success(), with normal logText, without logType');
beautyLog.warn('beautylog.warn(), with normal logText, without logType');
console.log('');
console.log('logType String:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.log('beautylog.log(), with normal logText, with logType "dir"','dir');
beautyLog.log('beautylog.log(), with normal logText, with logType "error"','error');
beautyLog.log('beautylog.log(), with normal logText, with logType "info"','info');
beautyLog.log('beautylog.log(), with normal logText, with logType "ok"','ok');
beautyLog.log('beautylog.log(), with normal logText, with logType "success"','success');
beautyLog.log('beautylog.log(), with normal logText, with logType "warn"','warn');
console.log ('');
console.log('*** end OS console test ***');
console.log("*** start table test ***");
(function(){
var testTable1 = beautyLog.table.new("checks");
testTable1.push(['check1','success']);
testTable1.push(['check2','error']);
testTable1.push(['check3','error']);
testTable1.print();
var testTable2 = beautyLog.table.new("custom",["Column1".red,"Column2".blue,"Column3".cyan]);
testTable2.push(["Hey","this","works"]);
testTable2.print();
})();
var testTable2 = beautylog.table.new("custom",["Column1".red,"Column2".blue,"Column3".cyan]);
testTable2.push(["Hey","this","works"]);
testTable2.print();
})();
});
});
describe(".code",function(){
it("should highlight code",function(){
this.timeout(10000);
beautylog.code(
"var test = 3;\nfunction(){\n var hello = \"super\"\n};\nvar test;",
{
language:"javascript"
}
);
})
})
});
console.log("*** end table test ***");
console.log("*** start code test ***");
beautyLog.code(
"var test = 3; function(){}\n",
{
language:"javascript"
}
);

7
ts/typings.json Normal file
View File

@ -0,0 +1,7 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
}
}

3
ts/typings/browser.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="browser/ambient/colors/colors.d.ts" />
/// <reference path="browser/ambient/mocha/mocha.d.ts" />
/// <reference path="browser/ambient/node/node.d.ts" />

View File

@ -1,3 +1,5 @@
// Compiled using typings@0.6.5
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/colors/colors.d.ts
// Type definitions for Colors.js 0.6.0-1
// Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
@ -120,4 +122,4 @@ interface String {
america: string;
trap: string;
random: string;
}
}

View File

@ -0,0 +1,40 @@
// Compiled using typings@0.6.5
// Source: https://raw.githubusercontent.com/Bartvds/tsd-deftools/master/typings/DefinitelyTyped/mocha/mocha.d.ts
// Type definitions for mocha 1.9.0
// Project: http://visionmedia.github.io/mocha/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
declare var describe : {
(description: string, spec: () => void): void;
only(description: string, spec: () => void): void;
skip(description: string, spec: () => void): void;
timeout(ms: number);
}
declare var it: {
(expectation: string, assertion?: () => void): void;
(expectation: string, assertion?: (done: () => void) => void): void;
only(expectation: string, assertion?: () => void): void;
only(expectation: string, assertion?: (done: () => void) => void): void;
skip(expectation: string, assertion?: () => void): void;
skip(expectation: string, assertion?: (done: () => void) => void): void;
timeout(ms: number);
};
declare function before(action: () => void): void;
declare function before(action: (done: () => void) => void): void;
declare function aftet(action: () => void): void;
declare function after(action: (done: () => void) => void): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: () => void) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: () => void) => void): void;

View File

@ -1,14 +1,21 @@
// Type definitions for Node.js v0.12.0
// Compiled using typings@0.6.5
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/node/node.d.ts
// Type definitions for Node.js v4.x
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/************************************************
* *
* Node.js v0.12.0 API *
* Node.js v4.x API *
* *
************************************************/
interface Error {
stack?: string;
}
// compat for TypeScript 1.5.3
// if you use with --target es3 or --target es5 and use below definitions,
// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3.
@ -108,13 +115,19 @@ declare var Buffer: {
* @param array The octets to store.
*/
new (array: any[]): Buffer;
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
new (buffer: Buffer): Buffer;
prototype: Buffer;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
isBuffer(obj: any): boolean;
isBuffer(obj: any): obj is Buffer;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
@ -168,9 +181,11 @@ declare module NodeJS {
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
setMaxListeners(n: number): EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
}
export interface ReadableStream extends EventEmitter {
@ -188,8 +203,7 @@ declare module NodeJS {
export interface WritableStream extends EventEmitter {
writable: boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(buffer: Buffer|string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
@ -252,7 +266,7 @@ declare module NodeJS {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@ -330,6 +344,7 @@ declare module NodeJS {
undefined: typeof undefined;
unescape: (str: string) => string;
gc: () => void;
v8debug?: any;
}
export interface Timer {
@ -373,21 +388,22 @@ interface NodeBuffer {
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset: number, noAssert?: boolean): void;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): void;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): void;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): void;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): void;
writeInt8(value: number, offset: number, noAssert?: boolean): void;
writeInt16LE(value: number, offset: number, noAssert?: boolean): void;
writeInt16BE(value: number, offset: number, noAssert?: boolean): void;
writeInt32LE(value: number, offset: number, noAssert?: boolean): void;
writeInt32BE(value: number, offset: number, noAssert?: boolean): void;
writeFloatLE(value: number, offset: number, noAssert?: boolean): void;
writeFloatBE(value: number, offset: number, noAssert?: boolean): void;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void;
fill(value: any, offset?: number, end?: number): void;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): Buffer;
indexOf(value: string | number | Buffer, byteOffset?: number): number;
}
/************************************************
@ -400,25 +416,39 @@ declare module "buffer" {
}
declare module "querystring" {
export function stringify(obj: any, sep?: string, eq?: string): string;
export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any;
export interface StringifyOptions {
encodeURIComponent?: Function;
}
export interface ParseOptions {
maxKeys?: number;
decodeURIComponent?: Function;
}
export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
export function parse<T extends {}>(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
export function escape(str: string): string;
export function unescape(str: string): string;
}
declare module "events" {
export class EventEmitter implements NodeJS.EventEmitter {
static listenerCount(emitter: EventEmitter, event: string): number;
static EventEmitter: EventEmitter;
static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
static defaultMaxListeners: number;
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;
setMaxListeners(n: number): EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
}
listenerCount(type: string): number;
}
}
declare module "http" {
@ -426,6 +456,21 @@ declare module "http" {
import * as net from "net";
import * as stream from "stream";
export interface RequestOptions {
protocol?: string;
host?: string;
hostname?: string;
family?: number;
port?: number;
localAddress?: string;
socketPath?: string;
method?: string;
path?: string;
headers?: { [key: string]: any };
auth?: string;
agent?: Agent|boolean;
}
export interface Server extends events.EventEmitter {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server;
listen(port: number, hostname?: string, callback?: Function): Server;
@ -454,6 +499,7 @@ declare module "http" {
writeHead(statusCode: number, headers?: any): void;
statusCode: number;
statusMessage: string;
headersSent: boolean;
setHeader(name: string, value: string): void;
sendDate: boolean;
getHeader(name: string): string;
@ -563,7 +609,7 @@ declare module "http" {
};
export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server;
export function createClient(port?: number, host?: string): any;
export function request(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
export var globalAgent: Agent;
}
@ -599,6 +645,13 @@ declare module "cluster" {
// Event emitter
export function addListener(event: string, listener: Function): void;
export function on(event: "disconnect", listener: (worker: Worker) => void): void;
export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void;
export function on(event: "fork", listener: (worker: Worker) => void): void;
export function on(event: "listening", listener: (worker: Worker, address: any) => void): void;
export function on(event: "message", listener: (worker: Worker, message: any) => void): void;
export function on(event: "online", listener: (worker: Worker) => void): void;
export function on(event: "setup", listener: (settings: any) => void): void;
export function on(event: string, listener: Function): any;
export function once(event: string, listener: Function): void;
export function removeListener(event: string, listener: Function): void;
@ -678,7 +731,29 @@ declare module "zlib" {
}
declare module "os" {
export interface CpuInfo {
model: string;
speed: number;
times: {
user: number;
nice: number;
sys: number;
idle: number;
irq: number;
};
}
export interface NetworkInterfaceInfo {
address: string;
netmask: string;
family: string;
mac: string;
internal: boolean;
}
export function tmpdir(): string;
export function homedir(): string;
export function endianness(): string;
export function hostname(): string;
export function type(): string;
export function platform(): string;
@ -688,8 +763,8 @@ declare module "os" {
export function loadavg(): number[];
export function totalmem(): number;
export function freemem(): number;
export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[];
export function networkInterfaces(): any;
export function cpus(): CpuInfo[];
export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]};
export var EOL: string;
}
@ -713,15 +788,7 @@ declare module "https" {
SNICallback?: (servername: string) => any;
}
export interface RequestOptions {
host?: string;
hostname?: string;
port?: number;
path?: string;
method?: string;
headers?: any;
auth?: string;
agent?: any;
export interface RequestOptions extends http.RequestOptions{
pfx?: any;
key?: any;
passphrase?: string;
@ -729,6 +796,7 @@ declare module "https" {
ca?: any;
ciphers?: string;
rejectUnauthorized?: boolean;
secureProtocol?: string;
}
export interface Agent {
@ -753,7 +821,7 @@ declare module "punycode" {
export function toASCII(domain: string): string;
export var ucs2: ucs2;
interface ucs2 {
decode(string: string): string;
decode(string: string): number[];
encode(codePoints: number[]): string;
}
export var version: any;
@ -781,22 +849,49 @@ declare module "readline" {
import * as events from "events";
import * as stream from "stream";
export interface Key {
sequence?: string;
name?: string;
ctrl?: boolean;
meta?: boolean;
shift?: boolean;
}
export interface ReadLine extends events.EventEmitter {
setPrompt(prompt: string): void;
prompt(preserveCursor?: boolean): void;
question(query: string, callback: Function): void;
pause(): void;
resume(): void;
question(query: string, callback: (answer: string) => void): void;
pause(): ReadLine;
resume(): ReadLine;
close(): void;
write(data: any, key?: any): void;
write(data: string|Buffer, key?: Key): void;
}
export interface Completer {
(line: string): CompleterResult;
(line: string, callback: (err: any, result: CompleterResult) => void): any;
}
export interface CompleterResult {
completions: string[];
line: string;
}
export interface ReadLineOptions {
input: NodeJS.ReadableStream;
output: NodeJS.WritableStream;
completer?: Function;
output?: NodeJS.WritableStream;
completer?: Completer;
terminal?: boolean;
historySize?: number;
}
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
export function createInterface(options: ReadLineOptions): ReadLine;
export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void;
export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
export function clearScreenDown(stream: NodeJS.WritableStream): void;
}
declare module "vm" {
@ -856,14 +951,38 @@ declare module "child_process" {
env?: any;
encoding?: string;
timeout?: number;
maxBuffer?: string;
maxBuffer?: number;
killSignal?: string;
}, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
export function fork(modulePath: string, args?: string[], options?: {
cwd?: string;
env?: any;
encoding?: string;
execPath?: string;
execArgv?: string[];
silent?: boolean;
uid?: number;
gid?: number;
}): ChildProcess;
export function spawnSync(command: string, args?: string[], options?: {
cwd?: string;
input?: string | Buffer;
stdio?: any;
env?: any;
uid?: number;
gid?: number;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
encoding?: string;
}): {
pid: number;
output: string[];
stdout: string | Buffer;
stderr: string | Buffer;
status: number;
signal: string;
error: Error;
};
export function execSync(command: string, options?: {
cwd?: string;
input?: string|Buffer;
@ -875,7 +994,7 @@ declare module "child_process" {
maxBuffer?: number;
killSignal?: string;
encoding?: string;
}): ChildProcess;
}): string | Buffer;
export function execFileSync(command: string, args?: string[], options?: {
cwd?: string;
input?: string|Buffer;
@ -887,26 +1006,12 @@ declare module "child_process" {
maxBuffer?: number;
killSignal?: string;
encoding?: string;
}): ChildProcess;
}): string | Buffer;
}
declare module "url" {
export interface Url {
href: string;
protocol: string;
auth: string;
hostname: string;
port: string;
host: string;
pathname: string;
search: string;
query: any; // string | Object
slashes: boolean;
hash?: string;
path?: string;
}
export interface UrlOptions {
href?: string;
protocol?: string;
auth?: string;
hostname?: string;
@ -914,13 +1019,14 @@ declare module "url" {
host?: string;
pathname?: string;
search?: string;
query?: any;
query?: any; // string | Object
slashes?: boolean;
hash?: string;
path?: string;
}
export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
export function format(url: UrlOptions): string;
export function format(url: Url): string;
export function resolve(from: string, to: string): string;
}
@ -996,10 +1102,10 @@ declare module "net" {
}
export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(port: number, host?: string, connectionListener?: Function): Socket;
export function connect(path: string, connectionListener?: Function): Socket;
export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
export function createConnection(path: string, connectionListener?: Function): Socket;
export function isIP(input: string): number;
@ -1062,6 +1168,7 @@ declare module "fs" {
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
}
interface FSWatcher extends events.EventEmitter {
@ -1214,6 +1321,9 @@ declare module "fs" {
export function fsyncSync(fd: number): 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 write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => 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;
@ -1302,21 +1412,15 @@ declare module "fs" {
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
fd?: string;
fd?: number;
mode?: number;
bufferSize?: number;
}): ReadStream;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
fd?: string;
mode?: string;
bufferSize?: number;
autoClose?: boolean;
}): ReadStream;
export function createWriteStream(path: string, options?: {
flags?: string;
encoding?: string;
string?: string;
fd?: number;
mode?: number;
}): WriteStream;
}
@ -1485,6 +1589,8 @@ declare module "tls" {
var CLIENT_RENEG_WINDOW: number;
export interface TlsOptions {
host?: string;
port?: number;
pfx?: any; //string or buffer
key?: any; //string or buffer
passphrase?: string;
@ -1591,13 +1697,13 @@ declare module "crypto" {
export function createHash(algorithm: string): Hash;
export function createHmac(algorithm: string, key: string): Hmac;
export function createHmac(algorithm: string, key: Buffer): Hmac;
interface Hash {
export interface Hash {
update(data: any, input_encoding?: string): Hash;
digest(encoding: 'buffer'): Buffer;
digest(encoding: string): any;
digest(): Buffer;
}
interface Hmac {
export interface Hmac extends NodeJS.ReadWriteStream {
update(data: any, input_encoding?: string): Hmac;
digest(encoding: 'buffer'): Buffer;
digest(encoding: string): any;
@ -1605,7 +1711,7 @@ declare module "crypto" {
}
export function createCipher(algorithm: string, password: any): Cipher;
export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
interface Cipher {
export interface Cipher {
update(data: Buffer): Buffer;
update(data: string, input_encoding?: string, output_encoding?: string): string;
final(): Buffer;
@ -1614,7 +1720,7 @@ declare module "crypto" {
}
export function createDecipher(algorithm: string, password: any): Decipher;
export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
interface Decipher {
export interface Decipher {
update(data: Buffer): Buffer;
update(data: string, input_encoding?: string, output_encoding?: string): string;
final(): Buffer;
@ -1622,18 +1728,18 @@ declare module "crypto" {
setAutoPadding(auto_padding: boolean): void;
}
export function createSign(algorithm: string): Signer;
interface Signer {
export interface Signer extends NodeJS.WritableStream {
update(data: any): void;
sign(private_key: string, output_format: string): string;
}
export function createVerify(algorith: string): Verify;
interface Verify {
export interface Verify extends NodeJS.WritableStream {
update(data: any): void;
verify(object: string, signature: string, signature_format?: string): boolean;
}
export function createDiffieHellman(prime_length: number): DiffieHellman;
export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman;
interface DiffieHellman {
export interface DiffieHellman {
generateKeys(encoding?: string): string;
computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string;
getPrime(encoding?: string): string;
@ -1644,10 +1750,10 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : 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;
@ -1657,7 +1763,7 @@ declare module "crypto" {
declare module "stream" {
import * as events from "events";
export interface Stream extends events.EventEmitter {
export class Stream extends events.EventEmitter {
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
}
@ -1671,14 +1777,13 @@ declare module "stream" {
readable: boolean;
constructor(opts?: ReadableOptions);
_read(size: number): void;
read(size?: number): string|Buffer;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): 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: Buffer): void;
unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
}
@ -1686,20 +1791,18 @@ declare module "stream" {
export interface WritableOptions {
highWaterMark?: number;
decodeStrings?: boolean;
objectMode?: boolean;
}
export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
writable: boolean;
constructor(opts?: WritableOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
_write(chunk: any, encoding: string, callback: Function): void;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, 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;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface DuplexOptions extends ReadableOptions, WritableOptions {
@ -1710,15 +1813,12 @@ declare module "stream" {
export class Duplex extends Readable implements NodeJS.ReadWriteStream {
writable: boolean;
constructor(opts?: DuplexOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
_write(chunk: any, encoding: string, callback: Function): void;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, 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;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export interface TransformOptions extends ReadableOptions, WritableOptions {}
@ -1728,8 +1828,7 @@ declare module "stream" {
readable: boolean;
writable: boolean;
constructor(opts?: TransformOptions);
_transform(chunk: Buffer, encoding: string, callback: Function): void;
_transform(chunk: string, encoding: string, callback: Function): void;
_transform(chunk: any, encoding: string, callback: Function): void;
_flush(callback: Function): void;
read(size?: number): any;
setEncoding(encoding: string): void;
@ -1737,17 +1836,14 @@ declare module "stream" {
resume(): 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: Buffer): void;
unshift(chunk: any): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
write(chunk: any, cb?: Function): boolean;
write(chunk: any, 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;
end(chunk: any, cb?: Function): void;
end(chunk: any, encoding?: string, cb?: Function): void;
}
export class PassThrough extends Transform {}
@ -1774,6 +1870,7 @@ declare module "util" {
export function isDate(object: any): boolean;
export function isError(object: any): boolean;
export function inherits(constructor: any, superConstructor: any): void;
export function debuglog(key:string): (msg:string,...param: any[])=>void;
}
declare module "assert" {
@ -1799,6 +1896,8 @@ declare module "assert" {
export function notDeepEqual(acutal: any, expected: any, message?: string): void;
export function strictEqual(actual: any, expected: any, message?: string): void;
export function notStrictEqual(actual: any, expected: any, message?: string): void;
export function deepStrictEqual(actual: any, expected: any, message?: string): void;
export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
export var throws: {
(block: Function, message?: string): void;
(block: Function, error: Function, message?: string): void;
@ -1826,10 +1925,12 @@ declare module "tty" {
export interface ReadStream extends net.Socket {
isRaw: boolean;
setRawMode(mode: boolean): void;
isTTY: boolean;
}
export interface WriteStream extends net.Socket {
columns: number;
rows: number;
isTTY: boolean;
}
}
@ -2076,4 +2177,4 @@ declare module "constants" {
export var W_OK: number;
export var X_OK: number;
export var UV_UDP_REUSEADDR: number;
}
}

3
ts/typings/main.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="main/ambient/colors/colors.d.ts" />
/// <reference path="main/ambient/mocha/mocha.d.ts" />
/// <reference path="main/ambient/node/node.d.ts" />

View File

@ -0,0 +1,125 @@
// Compiled using typings@0.6.5
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/colors/colors.d.ts
// Type definitions for Colors.js 0.6.0-1
// Project: https://github.com/Marak/colors.js
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "colors" {
interface Color {
(text: string): string;
black: Color;
red: Color;
green: Color;
yellow: Color;
blue: Color;
magenta: Color;
cyan: Color;
white: Color;
gray: Color;
grey: Color;
bgBlack: Color;
bgRed: Color;
bgGreen: Color;
bgYellow: Color;
bgBlue: Color;
bgMagenta: Color;
bgCyan: Color;
bgWhite: Color;
reset: Color;
bold: Color;
dim: Color;
italic: Color;
underline: Color;
inverse: Color;
hidden: Color;
strikethrough: Color;
rainbow: Color;
zebra: Color;
america: Color;
trap: Color;
random: Color;
}
module e {
export function setTheme(theme:any): void;
export var black: Color;
export var red: Color;
export var green: Color;
export var yellow: Color;
export var blue: Color;
export var magenta: Color;
export var cyan: Color;
export var white: Color;
export var gray: Color;
export var grey: Color;
export var bgBlack: Color;
export var bgRed: Color;
export var bgGreen: Color;
export var bgYellow: Color;
export var bgBlue: Color;
export var bgMagenta: Color;
export var bgCyan: Color;
export var bgWhite: Color;
export var reset: Color;
export var bold: Color;
export var dim: Color;
export var italic: Color;
export var underline: Color;
export var inverse: Color;
export var hidden: Color;
export var strikethrough: Color;
export var rainbow: Color;
export var zebra: Color;
export var america: Color;
export var trap: Color;
export var random: Color;
}
export = e;
}
interface String {
black: string;
red: string;
green: string;
yellow: string;
blue: string;
magenta: string;
cyan: string;
white: string;
gray: string;
grey: string;
bgBlack: string;
bgRed: string;
bgGreen: string;
bgYellow: string;
bgBlue: string;
bgMagenta: string;
bgCyan: string;
bgWhite: string;
reset: string;
bold: string;
dim: string;
italic: string;
underline: string;
inverse: string;
hidden: string;
strikethrough: string;
rainbow: string;
zebra: string;
america: string;
trap: string;
random: string;
}

View File

@ -0,0 +1,40 @@
// Compiled using typings@0.6.5
// Source: https://raw.githubusercontent.com/Bartvds/tsd-deftools/master/typings/DefinitelyTyped/mocha/mocha.d.ts
// Type definitions for mocha 1.9.0
// Project: http://visionmedia.github.io/mocha/
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
declare var describe : {
(description: string, spec: () => void): void;
only(description: string, spec: () => void): void;
skip(description: string, spec: () => void): void;
timeout(ms: number);
}
declare var it: {
(expectation: string, assertion?: () => void): void;
(expectation: string, assertion?: (done: () => void) => void): void;
only(expectation: string, assertion?: () => void): void;
only(expectation: string, assertion?: (done: () => void) => void): void;
skip(expectation: string, assertion?: () => void): void;
skip(expectation: string, assertion?: (done: () => void) => void): void;
timeout(ms: number);
};
declare function before(action: () => void): void;
declare function before(action: (done: () => void) => void): void;
declare function aftet(action: () => void): void;
declare function after(action: (done: () => void) => void): void;
declare function beforeEach(action: () => void): void;
declare function beforeEach(action: (done: () => void) => void): void;
declare function afterEach(action: () => void): void;
declare function afterEach(action: (done: () => void) => void): void;

2180
ts/typings/main/ambient/node/node.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

2
ts/typings/tsd.d.ts vendored
View File

@ -1,2 +0,0 @@
/// <reference path="node/node.d.ts" />
/// <reference path="colors/colors.d.ts" />