From 0690841c6b5d33bfcbf91be3b02f13e63c990ed1 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Mon, 10 Feb 2014 17:40:59 +0000 Subject: [PATCH 01/33] Update angular.d.ts The listener may take a single event argument. --- angularjs/angular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a8c1d991d..10dec18ae 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -227,6 +227,7 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From 045537ef49c478296abc3becf0ea5d27be326823 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 25 Feb 2014 17:32:17 +0000 Subject: [PATCH 02/33] Update angular-ui-router.d.ts --- angular-ui/angular-ui-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index da3d92e5e..285149a0d 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -84,6 +84,7 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; + $current: IState; params: IStateParamsService; } From 17e72ca4827f7d9f3e92b3322f0021771301b8cb Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 25 Feb 2014 17:37:58 +0000 Subject: [PATCH 03/33] Revert "Update angular.d.ts" This reverts commit 0690841c6b5d33bfcbf91be3b02f13e63c990ed1. --- angularjs/angular.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 10dec18ae..a8c1d991d 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -227,7 +227,6 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; - $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From c0df8aa594852cec97d841e28488d9b39b1c62ee Mon Sep 17 00:00:00 2001 From: Brian Malehorn Date: Mon, 21 Jul 2014 17:56:42 -0700 Subject: [PATCH 04/33] fix a number of bugs in d3.d.ts Most are a result of setter = foo.bar(x), getter = foo.bar() only reflecting the setter signature. --- d3/d3.d.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 598cd9f34..8da827f4e 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -243,7 +243,7 @@ declare module D3 { * * @param map Array of objects to get the values from */ - values(map: any[]): any[]; + values(map: any): any[]; /** * List the key-value entries of an associative array. * @@ -1720,10 +1720,21 @@ declare module D3 { (): any[]; (values: any[]): Axis; }; - tickSubdivide(count: number): Axis; - tickSize(major?: number, minor?: number, end?: number): Axis; + tickSize: { + (): number; + (inner: number, outer?: number): Axis; + } + innerTickSize: { + (): number; + (value: number): Axis; + } + outerTickSize: { + (): number; + (value: number): Axis; + } tickFormat(formatter: (value: any) => string): Axis; + nice(count?: number): Axis; } export interface Arc { @@ -2569,7 +2580,10 @@ declare module D3 { * * @param clamp Enable or disable */ - clamp(clamp: boolean): QuantitiveScale; + clamp: { + (): boolean; + (clamp: boolean): QuantitiveScale; + } /** * extend the scale domain to nice round numbers. * @@ -2587,7 +2601,7 @@ declare module D3 { * * @param count Aproximate representative values to return */ - tickFormat(count: number): (n: number) => string; + tickFormat(count: number, format?: string): (n: number) => string; /** * create a new scale from an existing scale.. */ @@ -2768,6 +2782,7 @@ declare module D3 { }; tickFormat(count: number): (n: number) => string; copy(): TimeScale; + nice(count?: number): TimeScale; } } From b8ce2bd4c01526630b8402af303824bf5341a572 Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Sun, 3 Aug 2014 16:41:25 -0500 Subject: [PATCH 05/33] updated mysql definitions and tests --- mysql/mysql-tests.ts | 381 +++++++++++++++++++++++++++++++++ mysql/mysql.d.ts | 488 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 869 insertions(+) create mode 100644 mysql/mysql-tests.ts create mode 100644 mysql/mysql.d.ts diff --git a/mysql/mysql-tests.ts b/mysql/mysql-tests.ts new file mode 100644 index 000000000..81f1e7766 --- /dev/null +++ b/mysql/mysql-tests.ts @@ -0,0 +1,381 @@ +/// + +import mysql = require('mysql'); + +/// Connections +var connection = mysql.createConnection({ + host: 'localhost', + user: 'me', + password: 'secret' +}); + +connection.connect(); + +connection.query('SELECT 1 + 1 AS solution', function (err, rows, fields) { + if (err) throw err; + + console.log('The solution is: ', rows[0].solution); +}); + +connection.end(); + +connection = mysql.createConnection({ + host: 'example.org', + user: 'bob', + password: 'secret' +}); + +connection.connect(function (err) { + if (err) { + console.error('error connecting: ' + err.stack); + return; + } + + console.log('connected as id ' + connection.threadId); +}); + +connection.query('SELECT 1', function (err, rows) { + // connected! (unless `err` is set) +}); + +connection = mysql.createConnection({ + host: 'localhost', + ssl: { + ca: '' + } +}); + +connection = mysql.createConnection({ + host: 'localhost', + ssl: { + // DO NOT DO THIS + // set up your ca correctly to trust the connection + rejectUnauthorized: false + } +}); + +connection.end(function (err) { + // The connection is terminated now +}); + +connection.destroy(); + +connection.changeUser({ user: 'john' }, function (err) { + if (err) throw err; +}); + +var userId = 'some user provided value'; +var sql = 'SELECT * FROM users WHERE id = ' + connection.escape(userId); +connection.query(sql, function (err, results) { + // ... +}); +connection.query('SELECT * FROM users WHERE id = ?', [userId], function (err, results) { + // ... +}); + +var post = { id: 1, title: 'Hello MySQL' }; +var query = connection.query('INSERT INTO posts SET ?', post, function (err, result) { + // Neat! +}); +console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL' + +var queryStr = "SELECT * FROM posts WHERE title=" + mysql.escape("Hello MySQL"); + +console.log(queryStr); // SELECT * FROM posts WHERE title='Hello MySQL' + +var sorter = 'date'; +var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter); +connection.query(sql, function (err, results) { + // ... +}); + +var sorter = 'date'; +var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId('posts.' + sorter); +connection.query(sql, function (err, results) { + // ... +}); + +var userIdNum = 1; +var columns = ['username', 'email']; +var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userIdNum], function (err, results) { + // ... +}); + +console.log(query.sql); // SELECT `username`, `email` FROM `users` WHERE id = 1 + +var sql = "SELECT * FROM ?? WHERE ?? = ?"; +var inserts = ['users', 'id', userId]; +sql = mysql.format(sql, inserts); + +connection.config.queryFormat = function (query, values) { + if (!values) return query; + return query.replace(/\:(\w+)/g, function (txt, key) { + if (values.hasOwnProperty(key)) { + return this.escape(values[key]); + } + return txt; + }.bind(this)); +}; + +connection.query("UPDATE posts SET title = :title", { title: "Hello MySQL" }); + +connection.query('INSERT INTO posts SET ?', { title: 'test' }, function (err, result) { + if (err) throw err; + + console.log(result.insertId); +}); + +connection.query('DELETE FROM posts WHERE title = "wrong"', function (err, result) { + if (err) throw err; + + console.log('deleted ' + result.affectedRows + ' rows'); +}); + +connection.query('UPDATE posts SET ...', function (err, result) { + if (err) throw err; + + console.log('changed ' + result.changedRows + ' rows'); +}); + +connection.connect(function (err) { + if (err) throw err; + console.log('connected as id ' + connection.threadId); +}); + +/// Pools + +var poolConfig = { + connectionLimit: 10, + host: 'example.org', + user: 'bob', + password: 'secret' +}; + +var pool = mysql.createPool(poolConfig); + +pool.query('SELECT 1 + 1 AS solution', function (err, rows, fields) { + if (err) throw err; + + console.log('The solution is: ', rows[0].solution); +}); + +pool = mysql.createPool({ + host: 'example.org', + user: 'bob', + password: 'secret' +}); + +pool.getConnection(function (err, connection) { + // connected! (unless `err` is set) +}); + +pool.on('connection', function (connection) { + connection.query('SET SESSION auto_increment_increment=1') +}); + +pool.getConnection(function (err, connection: mysql.IConnection) { + // Use the connection + connection.query('SELECT something FROM sometable', function (err, rows) { + // And done with the connection. + connection.release(); + + // Don't use the connection here, it has been returned to the pool. + }); +}); + +/// PoolClusters + +// create +var poolCluster = mysql.createPoolCluster(); + +poolCluster.add(poolConfig); // anonymous group +poolCluster.add('MASTER', poolConfig); +poolCluster.add('SLAVE1', poolConfig); +poolCluster.add('SLAVE2', poolConfig); + +// Target Group : ALL(anonymous, MASTER, SLAVE1-2), Selector : round-robin(default) +poolCluster.getConnection(function (err, connection) { }); + +// Target Group : MASTER, Selector : round-robin +poolCluster.getConnection('MASTER', function (err, connection) { }); + +// Target Group : SLAVE1-2, Selector : order +// If can't connect to SLAVE1, return SLAVE2. (remove SLAVE1 in the cluster) +poolCluster.on('remove', function (nodeId) { + console.log('REMOVED NODE : ' + nodeId); // nodeId = SLAVE1 +}); + +poolCluster.getConnection('SLAVE*', 'ORDER', function (err, connection) { }); + +// of namespace : of(pattern, selector) +poolCluster.of('*').getConnection(function (err, connection) { }); + +var pool = poolCluster.of('SLAVE*', 'RANDOM'); +pool.getConnection(function (err, connection) { }); +pool.getConnection(function (err, connection) { }); + +// destroy +poolCluster.end(); + +/// Queries + +var query = connection.query('SELECT * FROM posts'); +query + .on('error', function (err) { + // Handle error, an 'end' event will be emitted after this as well + }) + .on('fields', function (fields) { + // the field packets for the rows to follow + }) + .on('result', function (row) { + // Pausing the connnection is useful if your processing involves I/O + connection.pause(); + + var processRow = (row: any, cb: () => void) => { + cb(); + }; + + processRow(row, function () { + connection.resume(); + }); + }) + .on('end', function () { + // all rows have been received + }); + +connection.query('SELECT * FROM posts') + .stream({ highWaterMark: 5 }) + .pipe(() => { }); + +connection = mysql.createConnection({ multipleStatements: true }); + +connection.query('SELECT 1; SELECT 2', function (err, results) { + if (err) throw err; + + // `results` is an array with one element for every statement in the query: + console.log(results[0]); // [{1: 1}] + console.log(results[1]); // [{2: 2}] +}); + +var query = connection.query('SELECT 1; SELECT 2'); + +query + .on('fields', function (fields, index) { + // the fields for the result rows that follow + }) + .on('result', function (row, index) { + // index refers to the statement this result belongs to (starts at 0) + }); + +var options = { sql: '...', nestTables: true }; + +connection.query(options, function (err, results) { + /* results will be an array like this now: + [{ + table1: { + fieldA: '...', + fieldB: '...', + }, + table2: { + fieldA: '...', + fieldB: '...', + }, + }, ...] + */ +}); + +connection.beginTransaction(function (err) { + var title = 'title'; + + if (err) { throw err; } + connection.query('INSERT INTO posts SET title=?', title, function (err, result) { + if (err) { + connection.rollback(function () { + throw err; + }); + } + + var log = 'Post ' + result.insertId + ' added'; + + connection.query('INSERT INTO log SET data=?', log, function (err, result) { + if (err) { + connection.rollback(function () { + throw err; + }); + } + connection.commit(function (err) { + if (err) { + connection.rollback(function () { + throw err; + }); + } + console.log('success!'); + }); + }); + }); +}); + +// Kill query after 60s +connection.query({ sql: 'SELECT COUNT(*) AS count FROM big_table', timeout: 60000 }, function (err, rows) { + if (err && err.code === 'PROTOCOL_SEQUENCE_TIMEOUT') { + throw new Error('too long to count table rows!'); + } + + if (err) { + throw err; + } + + console.log(rows[0].count + ' rows'); +}); + +connection = mysql.createConnection({ + port: 84943, // WRONG PORT +}); + +connection.connect(function (err) { + console.log(err.code); // 'ECONNREFUSED' + console.log(err.fatal); // true +}); + +connection.query('SELECT 1', function (err) { + console.log(err.code); // 'ECONNREFUSED' + console.log(err.fatal); // true +}); + +connection.query('USE name_of_db_that_does_not_exist', function (err, rows) { + console.log(err.code); // 'ER_BAD_DB_ERROR' +}); + +connection.query('SELECT 1', function (err, rows) { + console.log(err); // null + console.log(rows.length); // 1 +}); + +connection.on('error', function (err) { + console.log(err.code); // 'ER_BAD_DB_ERROR' +}); + +connection.query('USE name_of_db_that_does_not_exist'); + +// I am Chuck Norris: +connection.on('error', function () { }); + +connection = mysql.createConnection({ typeCast: false }); + +var query = connection.query({ sql: '...', typeCast: false }, function (err, results) { + +}); + +connection.query({ + sql: '...', + typeCast: function (field, next) { + if (field.type == 'TINY' && field.length == 1) { + return (field.string() == '1'); // 1 = true, 0 = false + } + return next(); + } +}); + +connection = mysql.createConnection("mysql://localhost/test?flags=-FOUND_ROWS"); +connection = mysql.createConnection({ debug: true }); +connection = mysql.createConnection({ debug: ['ComQueryPacket', 'RowDataPacket'] }); diff --git a/mysql/mysql.d.ts b/mysql/mysql.d.ts new file mode 100644 index 000000000..3df338e47 --- /dev/null +++ b/mysql/mysql.d.ts @@ -0,0 +1,488 @@ +// Type definitions for node-mysql +// Project: https://github.com/felixge/node-mysql +// Definitions by: William Johnston +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module mysql { + export interface IMySql { + createConnection(connectionUri: string): IConnection; + createConnection(config: IConnectionConfig): IConnection; + + createPool(config: IPoolConfig): IPool; + + createPoolCluster(config?: IPoolClusterConfig): IPoolCluster; + + escape(value: any): string; + + format(sql: string): string; + format(sql: string, values: Array): string; + } + + export interface IConnectionStatic { + createQuery(sql: string): IQuery; + createQuery(sql: string, callback: (err: IError, ...args: any[]) => void): IQuery; + createQuery(sql: string, values: Array): IQuery; + createQuery(sql: string, values: Array, callback: (err: IError, ...args: any[]) => void): IQuery; + } + + export interface IConnection { + config: IConnectionConfig; + + threadId: number; + + beginTransaction(callback: (err: IError) => void): void; + + connect(): void; + connect(callback: (err: IError, ...args: any[]) => void): void; + connect(options: any, callback?: (err: IError, ...args: any[]) => void): void; + + commit(callback: (err: IError) => void): void; + + changeUser(options: IConnectionOptions): void; + changeUser(options: IConnectionOptions, callback: (err: IError) => void): void; + + query: IQueryFunction; + + end(): void; + end(options: any): void; + end(callback: (err: IError, ...args: any[]) => void): void; + end(options: any, callback: (err: IError, ...args: any[]) => void): void; + + destroy(): void; + + pause(): void; + + release(): void; + resume(): void; + + escape(value: any): string; + + escapeId(value: string): string; + escapeId(values: Array): string; + + format(sql: string): string; + format(sql: string, values: Array): string; + + on(ev: string, callback: (...args: any[]) => void): IConnection; + on(ev: 'error', callback: (err: IError) => void): IConnection; + + rollback(callback: () => void): void; + } + + export interface IPool { + config: IPoolConfig; + + getConnection(callback: (err: IError, connection: IConnection) => void): void; + + query: IQueryFunction; + + on(ev: string, callback: (...args: any[]) => void): IPool; + on(ev: 'connection', callback: (connection: IConnection) => void): IPool; + on(ev: 'error', callback: (err: IError) => void): IPool; + } + + export interface IPoolCluster { + config: IPoolClusterConfig; + + add(config: IPoolConfig): void; + add(group: string, config: IPoolConfig): void; + + end(): void; + + getConnection(callback: (err: IError, connection: IConnection) => void): void; + getConnection(group: string, callback: (err: IError, connection: IConnection) => void): void; + getConnection(group: string, selector: string, callback: (err: IError, connection: IConnection) => void): void; + + of(pattern: string): IPool; + of(pattern: string, selector: string): IPool; + + on(ev: string, callback: (...args: any[]) => void): IPoolCluster; + on(ev: 'remove', callback: (nodeId: number) => void): IPoolCluster; + on(ev: 'connection', callback: (connection: IConnection) => void): IPoolCluster; + on(ev: 'error', callback: (err: IError) => void): IPoolCluster; + } + + export interface IQuery { + /** + * The SQL for a constructed query + */ + sql: string; + + /** + * Emits a query packet to start the query + */ + start(): void; + + /** + * Determines the packet class to use given the first byte of the packet. + * + * @param firstByte The first byte of the packet + * @param parser The packet parser + */ + determinePacket(firstByte: number, parser: any): any; + + /** + * Creates a Readable stream with the given options + * + * @param options The options for the stream. + */ + stream(options: IStreamOptions): IQuery; + + /** + * Pipes a stream downstream, providing automatic pause/resume based on the + * options sent to the stream. + * + * @param options The options for the stream. + */ + pipe(callback: (...args: any[]) => void): IQuery; + + on(ev: string, callback: (...args: any[]) => void): IQuery; + on(ev: 'error', callback: (err: IError) => void): IQuery; + on(ev: 'fields', callback: (fields: any, index: number) => void): IQuery; + on(ev: 'result', callback: (row: any, index: number) => void): IQuery; + on(ev: 'end', callback: () => void): IQuery; + } + + export interface IQueryFunction { + (sql: string): IQuery; + (sql: string, callback: (err: IError, ...args: any[]) => void): IQuery; + (sql: string, values: Array): IQuery; + (sql: string, values: Array, callback: (err: IError, ...args: any[]) => void): IQuery; + (sql: string, values: any): IQuery; + (sql: string, values: any, callback: (err: IError, ...args: any[]) => void): IQuery; + (options: IQueryOptions): IQuery; + (options: IQueryOptions, callback: (err: IError, ...args: any[]) => void): IQuery; + (options: IQueryOptions, values: Array): IQuery; + (options: IQueryOptions, values: Array, callback: (err: IError, ...args: any[]) => void): IQuery; + (options: IQueryOptions, values: any): IQuery; + (options: IQueryOptions, values: any, callback: (err: IError, ...args: any[]) => void): IQuery; + } + + export interface IQueryOptions { + /** + * The SQL for the query + */ + sql: string; + + /** + * Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for + * operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout + * operations through the client. This means that when a timeout is reached, the connection it occurred on will be + * destroyed and no further operations can be performed. + */ + timeout?: number; + + /** + * Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be + * nested as tableName_fieldName + */ + nestTables?: any; + + /** + * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future) + * to disable type casting, but you can currently do so on either the connection or query level. (Default: true) + * + * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself. + * + * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once. + * + * field.string() + * field.buffer() + * field.geometry() + * + * are aliases for + * + * parser.parseLengthCodedString() + * parser.parseLengthCodedBuffer() + * parser.parseGeometryValue() + * + * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast + */ + typeCast?: any; + } + + export interface IStreamOptions { + /** + * Sets the max buffer size in objects of a stream + */ + highWaterMark?: number; + + /** + * The object mode of the stream (Default: true) + */ + objectMode?: any; + } + + export interface IConnectionOptions { + /** + * The MySQL user to authenticate as + */ + user?: string; + + /** + * The password of that MySQL user + */ + password?: string; + + /** + * Name of the database to use for this connection + */ + database?: string; + + /** + * The charset for the connection. This is called "collation" in the SQL-level of MySQL (like utf8_general_ci). + * If a SQL-level charset is specified (like utf8mb4) then the default collation for that charset is used. + * (Default: 'UTF8_GENERAL_CI') + */ + charset?: string; + } + + export interface IConnectionConfig extends IConnectionOptions { + /** + * The hostname of the database you are connecting to. (Default: localhost) + */ + host?: string; + + /** + * The port number to connect to. (Default: 3306) + */ + port?: number; + + /** + * The source IP address to use for TCP connection + */ + localAddress?: string; + + /** + * The path to a unix domain socket to connect to. When used host and port are ignored + */ + socketPath?: string; + + /** + * The timezone used to store local dates. (Default: 'local') + */ + timezone?: string; + + /** + * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds) + */ + connectTimeout?: number; + + /** + * Stringify objects instead of converting to values. (Default: 'false') + */ + stringifyObjects?: boolean; + + /** + * Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false) + */ + insecureAuth?: boolean; + + /** + * Determines if column values should be converted to native JavaScript types. It is not recommended (and may go away / change in the future) + * to disable type casting, but you can currently do so on either the connection or query level. (Default: true) + * + * You can also specify a function (field: any, next: () => void) => {} to do the type casting yourself. + * + * WARNING: YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once. + * + * field.string() + * field.buffer() + * field.geometry() + * + * are aliases for + * + * parser.parseLengthCodedString() + * parser.parseLengthCodedBuffer() + * parser.parseGeometryValue() + * + * You can find which field function you need to use by looking at: RowDataPacket.prototype._typeCast + */ + typeCast?: any; + + /** + * A custom query format function + */ + queryFormat?: (query: string, values: any) => void; + + /** + * When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option + * (Default: false) + */ + supportBigNumbers?: boolean; + + /** + * Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be + * always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving + * bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately + * represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5) + * (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. + * This option is ignored if supportBigNumbers is disabled. + */ + bigNumberStrings?: boolean; + + /** + * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date + * objects. (Default: false) + */ + dateStrings?: boolean; + + /** + * This will print all incoming and outgoing packets on stdout. + * You can also restrict debugging to packet types by passing an array of types (strings) to debug; + * + * (Default: false) + */ + debug?: any; + + /** + * Generates stack traces on Error to include call site of library entrance ("long stack traces"). Slight + * performance penalty for most calls. (Default: true) + */ + trace?: boolean; + + /** + * Allow multiple mysql statements per query. Be careful with this, it exposes you to SQL injection attacks. (Default: false) + */ + multipleStatements?: boolean; + + /** + * List of connection flags to use other than the default ones. It is also possible to blacklist default ones + */ + flags?: Array; + + /** + * object with ssl parameters or a string containing name of ssl profile + */ + ssl?: any; + } + + export interface IPoolConfig extends IConnectionConfig { + /** + * The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout, + * because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds) + */ + acquireTimeout?: number; + + /** + * Determines the pool's action when no connections are available and the limit has been reached. If true, the pool will queue + * the connection request and call it when one becomes available. If false, the pool will immediately call back with an error. + * (Default: true) + */ + waitForConnections?: boolean; + + /** + * The maximum number of connections to create at once. (Default: 10) + */ + connectionLimit?: number; + + /** + * The maximum number of connection requests the pool will queue before returning an error from getConnection. If set to 0, there + * is no limit to the number of queued connection requests. (Default: 0) + */ + queueLimit?: number; + } + + export interface IPoolClusterConfig { + /** + * If true, PoolCluster will attempt to reconnect when connection fails. (Default: true) + */ + canRetry?: boolean; + + /** + * If connection fails, node's errorCount increases. When errorCount is greater than removeNodeErrorCount, + * remove a node in the PoolCluster. (Default: 5) + */ + removeNodeErrorCount?: number; + + /** + * The default selector. (Default: RR) + * RR: Select one alternately. (Round-Robin) + * RANDOM: Select the node by random function. + * ORDER: Select the first node available unconditionally. + */ + defaultSelector?: string; + } + + export interface ISslCredentials { + /** + * A string or buffer holding the PFX or PKCS12 encoded private key, certificate and CA certificates + */ + pfx?: string; + + /** + * A string holding the PEM encoded private key + */ + key?: string; + + /** + * A string of passphrase for the private key or pfx + */ + passphrase?: string; + + /** + * A string holding the PEM encoded certificate + */ + cert?: string; + + /** + * Either a string or list of strings of PEM encoded CA certificates to trust. + */ + ca?: Array; + + /** + * Either a string or list of strings of PEM encoded CRLs (Certificate Revocation List) + */ + crl?: Array; + + /** + * A string describing the ciphers to use or exclude + */ + ciphers?: string; + } + + export interface IError extends Error { + /** + * Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'), + * a node.js error (e.g. 'ECONNREFUSED') or an internal error + * (e.g. 'PROTOCOL_CONNECTION_LOST'). + */ + code: string; + + /** + * The error number for the error code + */ + errno: number; + + /** + * The sql state marker + */ + sqlStateMarker?: string; + + /** + * The sql state + */ + sqlState?: string; + + /** + * The field count + */ + fieldCount?: number; + + /** + * The stack trace for the error + */ + stack?: string; + + /** + * Boolean, indicating if this error is terminal to the connection object. + */ + fatal: boolean; + } +} + +declare module 'mysql' { + var mysql: mysql.IMySql; + + export = mysql; +} From 4f562b1706cfdae66a74df298d0938151390f7a6 Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Sun, 3 Aug 2014 16:44:58 -0500 Subject: [PATCH 06/33] Fixed mysql tests --- mysql/mysql-tests.ts | 6 +++--- mysql/mysql.d.ts | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mysql/mysql-tests.ts b/mysql/mysql-tests.ts index 81f1e7766..83fdeb06a 100644 --- a/mysql/mysql-tests.ts +++ b/mysql/mysql-tests.ts @@ -109,7 +109,7 @@ sql = mysql.format(sql, inserts); connection.config.queryFormat = function (query, values) { if (!values) return query; - return query.replace(/\:(\w+)/g, function (txt, key) { + return query.replace(/\:(\w+)/g, function (txt: string, key: string) { if (values.hasOwnProperty(key)) { return this.escape(values[key]); } @@ -173,7 +173,7 @@ pool.on('connection', function (connection) { connection.query('SET SESSION auto_increment_increment=1') }); -pool.getConnection(function (err, connection: mysql.IConnection) { +pool.getConnection(function (err, connection) { // Use the connection connection.query('SELECT something FROM sometable', function (err, rows) { // And done with the connection. @@ -368,7 +368,7 @@ var query = connection.query({ sql: '...', typeCast: false }, function (err, res connection.query({ sql: '...', - typeCast: function (field, next) { + typeCast: function (field: any, next: Function) { if (field.type == 'TINY' && field.length == 1) { return (field.string() == '1'); // 1 = true, 0 = false } diff --git a/mysql/mysql.d.ts b/mysql/mysql.d.ts index 3df338e47..479b05266 100644 --- a/mysql/mysql.d.ts +++ b/mysql/mysql.d.ts @@ -44,7 +44,6 @@ declare module mysql { query: IQueryFunction; end(): void; - end(options: any): void; end(callback: (err: IError, ...args: any[]) => void): void; end(options: any, callback: (err: IError, ...args: any[]) => void): void; From 11737fa5b1cceb4401f7c7435b0da4bdc1c334c6 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Mon, 10 Feb 2014 17:40:59 +0000 Subject: [PATCH 07/33] Update angular.d.ts The listener may take a single event argument. --- angularjs/angular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e447985fb..59a33e715 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,6 +337,7 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From 783404bd8a37e11559f499ce16465d25d5c88f2f Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 25 Feb 2014 17:32:17 +0000 Subject: [PATCH 08/33] Update angular-ui-router.d.ts --- angular-ui/angular-ui-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 081d35723..889325aa4 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -85,6 +85,7 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; + $current: IState; params: IStateParamsService; reload(): void; } From 18ef03e31dfc89e937de12d43206f288c72d98b2 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 25 Feb 2014 17:37:58 +0000 Subject: [PATCH 09/33] Revert "Update angular.d.ts" This reverts commit 0690841c6b5d33bfcbf91be3b02f13e63c990ed1. --- angularjs/angular.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 59a33e715..e447985fb 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,7 +337,6 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; - $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From 9bdeb5e6c85654a38684cf2a4914d05706da64ce Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:01:21 +0100 Subject: [PATCH 10/33] Revert 783404b..18ef03e This rolls back to commit 783404bd8a37e11559f499ce16465d25d5c88f2f. --- angularjs/angular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e447985fb..59a33e715 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,6 +337,7 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From 8d1e03ff7791b3f4fc79846ba8995110d917a174 Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:01:40 +0100 Subject: [PATCH 11/33] Revert aec2fa9..9bdeb5e This rolls back to commit aec2fa9e392a883dfa4467ba12a6934f24d50a9e. --- angular-ui/angular-ui-router.d.ts | 1 - angularjs/angular.d.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 889325aa4..081d35723 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -85,7 +85,6 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; - $current: IState; params: IStateParamsService; reload(): void; } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 59a33e715..e447985fb 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,7 +337,6 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; - $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From d5ddb0544b0455cf20702f4af36d6c62e400f74e Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:02:13 +0100 Subject: [PATCH 12/33] Revert "Revert aec2fa9..9bdeb5e" This reverts commit 8d1e03ff7791b3f4fc79846ba8995110d917a174. --- angular-ui/angular-ui-router.d.ts | 1 + angularjs/angular.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 081d35723..889325aa4 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -85,6 +85,7 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; + $current: IState; params: IStateParamsService; reload(): void; } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e447985fb..59a33e715 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,6 +337,7 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From d17f3145a523e76a876e6d864c708f2d8cfb4dff Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:03:42 +0100 Subject: [PATCH 13/33] Revert "Revert "Revert aec2fa9..9bdeb5e"" This reverts commit d5ddb0544b0455cf20702f4af36d6c62e400f74e. --- angular-ui/angular-ui-router.d.ts | 1 - angularjs/angular.d.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 889325aa4..081d35723 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -85,7 +85,6 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; - $current: IState; params: IStateParamsService; reload(): void; } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 59a33e715..e447985fb 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -337,7 +337,6 @@ declare module ng { $new(isolate?: boolean): IScope; $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; - $on(name: string, listener: (event: IAngularEvent, eventArg: any) => any): Function; $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; From 24df639f25cd60e06b47cef6887b151ee6849749 Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:21:54 +0100 Subject: [PATCH 14/33] Add grunt.log.warn method --- gruntjs/gruntjs-tests.ts | 43 ++++++++++++++++++++++++++++++++++++++++ gruntjs/gruntjs.d.ts | 5 +++++ 2 files changed, 48 insertions(+) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index 853cac370..fe0f7ace9 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -73,3 +73,46 @@ exports = (grunt: IGrunt) => { fileMaps[0].src.length; fileMaps[0].dest; }; + +// Official grunt task template from +// https://github.com/gruntjs/grunt-init-gruntplugin/blob/master/root/tasks/name.js +exports.exports = function(grunt: IGrunt) { + + // Please see the Grunt documentation for more information regarding task + // creation: http://gruntjs.com/creating-tasks + + grunt.registerMultiTask('taskName', 'task description', function() { + // Merge task-specific and/or target-specific options with these defaults. + var options = this.options({ + punctuation: '.', + separator: ', ' + }); + + // Iterate over all specified file groups. + this.files.forEach(function(f) { + // Concat specified files. + var src = f.src.filter(function(filepath) { + // Warn on and remove invalid source files (if nonull was set). + if (!grunt.file.exists(filepath)) { + grunt.log.warn('Source file "' + filepath + '" not found.'); + return false; + } else { + return true; + } + }).map(function(filepath) { + // Read file source. + return grunt.file.read(filepath); + }).join(grunt.util.normalizelf(options.separator)); + + // Handle options. + src += options.punctuation; + + // Write the destination file. + grunt.file.write(f.dest, src); + + // Print a success message. + grunt.log.writeln('File "' + f.dest + '" created.'); + }); + }); + +}; \ No newline at end of file diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 86923c56e..8efa08ef6 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -690,6 +690,11 @@ declare module grunt { * Log a list of obj properties (good for debugging flags). */ writeflags(obj: any): T + + /** + * Log an warning with grunt.log.warn + */ + warn(msg: string): T } /** From 10c19f9b75e97ba6706da7aaea938ed411a5dcd9 Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:26:17 +0100 Subject: [PATCH 15/33] Revert "Merge branch 'master' of https://github.com/martinmcwhorter/DefinitelyTyped" This reverts commit 00124520f75bdc8151bc2c1427dd8dd5a2404a1b, reversing changes made to d17f3145a523e76a876e6d864c708f2d8cfb4dff. --- angular-ui/angular-ui-router.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 889325aa4..081d35723 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -85,7 +85,6 @@ declare module ng.ui { get(state: string): IState; get(): IState[]; current: IState; - $current: IState; params: IStateParamsService; reload(): void; } From 78289250ff3fdfd485eb11d55d133283797b906e Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:28:26 +0100 Subject: [PATCH 16/33] Revert old changes --- gruntjs/gruntjs-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index fe0f7ace9..6807cd96e 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -75,6 +75,7 @@ exports = (grunt: IGrunt) => { }; // Official grunt task template from +// Official grunt task template from // https://github.com/gruntjs/grunt-init-gruntplugin/blob/master/root/tasks/name.js exports.exports = function(grunt: IGrunt) { From f2d7f68db344ae9b7490523e22caf525f093306c Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 01:29:07 +0100 Subject: [PATCH 17/33] revert bad changes --- gruntjs/gruntjs-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index 6807cd96e..5fa560d86 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -74,7 +74,6 @@ exports = (grunt: IGrunt) => { fileMaps[0].dest; }; -// Official grunt task template from // Official grunt task template from // https://github.com/gruntjs/grunt-init-gruntplugin/blob/master/root/tasks/name.js exports.exports = function(grunt: IGrunt) { From b32f41a55cbd9a40a0d62c1b6e57fed486df43fa Mon Sep 17 00:00:00 2001 From: Saftpresse99 Date: Mon, 4 Aug 2014 09:58:08 +0200 Subject: [PATCH 18/33] Update angular-translate.d.ts Improvements ITranslateService --- angular-translate/angular-translate.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index 313ef8635..4b8da8449 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -33,13 +33,14 @@ declare module ng.translate { } interface ITranslateService { - (key: string, ...params: string[]): ng.IPromise; + (translationId: string, interpolateParams?: any, interpolationId?: string): ng.IPromise; + (translationId: string[], interpolateParams?: any, interpolationId?: string): ng.IPromise<{ [key: string]: string }>; cloakClassName(): string; cloakClassName(name: string): ITranslateProvider; fallbackLanguage(langKey?: string): string; fallbackLanguage(langKey?: string[]): string; instant(translationId: string, interpolateParams?: any, interpolationId?: string): string; - instant(translationId: string[], interpolateParams?: any, interpolationId?: string): string; + instant(translationId: string[], interpolateParams?: any, interpolationId?: string): { [key: string]: string }; isPostCompilingEnabled(): boolean; preferredLanguage(): string; proposedLanguage(): string; From 86ac984bb0e8019a2c0d583a07a5cbb6f0f18886 Mon Sep 17 00:00:00 2001 From: San Chen Date: Mon, 4 Aug 2014 16:16:54 +0800 Subject: [PATCH 19/33] needle definitions added --- CONTRIBUTORS.md | 1 + needle/needle-tests.ts | 14 ++++++++++++++ needle/needle.d.ts | 16 ++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 needle/needle-tests.ts create mode 100644 needle/needle.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index aafef048d..2bba0b895 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -249,6 +249,7 @@ All definitions files include a header with the author and editors, so at some p * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) * [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo)) +* [needle](https://github.com/tomas/needle) (by [San Chen](https://github.com/bigsan)) * [noble](https://github.com/sandeepmistry/noble) (by [Seon-Wook Park](https://github.com/swook)) * [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici)) * [Node.js](http://nodejs.org/) (from TypeScript samples) diff --git a/needle/needle-tests.ts b/needle/needle-tests.ts new file mode 100644 index 000000000..70c88933c --- /dev/null +++ b/needle/needle-tests.ts @@ -0,0 +1,14 @@ +/// + +import needle = require("needle"); + +var url = ""; +var options = {}; +var callback = (err, resp) => {}; + +needle.head(url, options, callback); +needle.get(url, options, callback); +needle.post(url, data, options, callback); +needle.put(url, data, options, callback); +needle.delete(url, data, options, callback); +needle.request(method, url, data, options, callback); diff --git a/needle/needle.d.ts b/needle/needle.d.ts new file mode 100644 index 000000000..732f5a059 --- /dev/null +++ b/needle/needle.d.ts @@ -0,0 +1,16 @@ +// Type definitions for needle 0.7.8 +// Project: https://github.com/tomas/needle +// Definitions by: San Chen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface INeedle { + head(url: string): IReadableStream; + head(url: string, callback?: Function): IReadableStream; + head(url: string, options?: any, callback?: Function): IReadableStream; + +} + +declare module "needle" { + var needle: INeedle; + export = needle; +} From 913218129823ae1659d5d539f5df61d9d277add0 Mon Sep 17 00:00:00 2001 From: martinmcwhorter Date: Mon, 4 Aug 2014 15:38:01 +0100 Subject: [PATCH 20/33] added missing type hints --- gruntjs/gruntjs-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index 5fa560d86..6b8607329 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -89,9 +89,9 @@ exports.exports = function(grunt: IGrunt) { }); // Iterate over all specified file groups. - this.files.forEach(function(f) { + this.files.forEach(function(f: grunt.file.IFilesConfig) { // Concat specified files. - var src = f.src.filter(function(filepath) { + var src = f.src.filter(function(filepath: string) { // Warn on and remove invalid source files (if nonull was set). if (!grunt.file.exists(filepath)) { grunt.log.warn('Source file "' + filepath + '" not found.'); From e49477e675eee56f171284a75066d58f85b76156 Mon Sep 17 00:00:00 2001 From: Will Johnston Date: Mon, 4 Aug 2014 09:46:50 -0500 Subject: [PATCH 21/33] Updated with mysql contributor --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index af326634b..c5096509b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -247,6 +247,7 @@ All definitions files include a header with the author and editors, so at some p * [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) * [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [mysql](https://github.com/felixge/node-mysql) (by [William Johnston](https://github.com/wjohnsto)) * [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo)) * [noble](https://github.com/sandeepmistry/noble) (by [Seon-Wook Park](https://github.com/swook)) * [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici)) From e3a212a892852cd4b8a5dccd6347ae32f4cfc187 Mon Sep 17 00:00:00 2001 From: Holger Stitz Date: Mon, 4 Aug 2014 17:02:03 +0200 Subject: [PATCH 22/33] Added the nodeSize function to TreeLayout Documentation https://github.com/mbostock/d3/wiki/Tree-Layout#nodeSize --- d3/d3.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 0354bc264..637afcc0c 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1159,6 +1159,19 @@ declare module D3 { */ (size: Array): TreeLayout; }; + /** + * Gets or sets the available node size + */ + nodeSize: { + /** + * Gets the available node size + */ + (): Array; + /** + * Sets the available node size + */ + (size: Array): TreeLayout; + }; } export interface PieLayout { From 7a8afe9eccb19ce169bdfddf05666e90e17d1f20 Mon Sep 17 00:00:00 2001 From: Evgenus Date: Mon, 4 Aug 2014 19:40:22 +0300 Subject: [PATCH 23/33] definitions for Big Integer library by Tom Wu --- CONTRIBUTORS.md | 1 + jsbn/jsbn-tests.ts | 93 +++++++++++++++++ jsbn/jsbn.d.ts | 250 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 344 insertions(+) create mode 100644 jsbn/jsbn-tests.ts create mode 100644 jsbn/jsbn.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index af326634b..8d25e840d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -193,6 +193,7 @@ All definitions files include a header with the author and editors, so at some p * [js-git](https://github.com/creationix/js-git) (by [Bart van der Schoor](https://github.com/Bartvds)) * [js-url](https://github.com/websanova/js-url) (by [MIZUNE Pine](https://github.com/pine613)) * [js-yaml](https://github.com/nodeca/js-yaml) (by [Bart van der Schoor](https://github.com/Bartvds/)) +* [jsbn](http://www-cs-students.stanford.edu/%7Etjw/jsbn/) (by [Eugene Chernyshov](https://github.com/Evgenus)) * [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz)) * [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk)) * [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) diff --git a/jsbn/jsbn-tests.ts b/jsbn/jsbn-tests.ts new file mode 100644 index 000000000..667f78553 --- /dev/null +++ b/jsbn/jsbn-tests.ts @@ -0,0 +1,93 @@ +/// +var BigInteger = jsbn.BigInteger; + +// constructor tests +var x = new BigInteger("AABB", 16); +x = new BigInteger("75643564363473453456342378564387956906736546456235345"); + +// method tests +var isBigInteger: jsbn.BigInteger; +var isNumber: number; +var isBoolean: boolean; +var isString: string; +var isDivmod: jsbn.BigInteger[]; +var isByteArray: number[]; + +x.copyTo(x); +x.fromInt(0); +x.fromString("CAFEBABE", 16); +x.clamp(); +isString = x.toString(); +isString = x.toString(16); +isBigInteger = x.negate(); +isBigInteger = x.abs(); +isNumber = x.compareTo(x); +isNumber = x.bitLength(); +x.dlShiftTo(0, isBigInteger); +x.drShiftTo(0, isBigInteger); +x.lShiftTo(0, isBigInteger); +x.rShiftTo(0, isBigInteger); +x.subTo(x, isBigInteger); +x.multiplyTo(x, isBigInteger); +x.squareTo(isBigInteger); +x.divRemTo(x, isBigInteger, isBigInteger); +isBigInteger = x.mod(x); +isNumber = x.invDigit(); +isBoolean = x.isEven(); +isBigInteger = x.exp(0, { + convert: (x) => x, + revert: (x) => x, + reduce: (x) => x, + mulTo: (x) => x, + sqrTo: (x) => x +}); +isBigInteger = x.modPowInt(0, x); +isBigInteger = x.clone(); +isNumber = x.intValue(); +isNumber = x.byteValue(); +isNumber = x.shortValue(); +isNumber = x.chunkSize(0); +isNumber = x.signum(); +isString = x.toRadix(10); +x.fromRadix("123", 10); +x.fromNumber(1); +x.fromNumber(1, 2); +x.fromNumber(1, 2, 3); +isByteArray = x.toByteArray(); +isBoolean = x.equals(x); +isBigInteger = x.min(x); +isBigInteger = x.max(x); +x.bitwiseTo(x, (x, y) => x + y, isBigInteger); +isBigInteger = x.and(x); +isBigInteger = x.or(x); +isBigInteger = x.xor(x); +isBigInteger = x.andNot(x); +isBigInteger = x.not(); +isBigInteger = x.shiftLeft(0); +isBigInteger = x.shiftRight(0); +isNumber = x.getLowestSetBit(); +isNumber = x.bitCount(); +isBoolean = x.testBit(0); +isBigInteger = x.changeBit(0, (x, y) => x * y); +isBigInteger = x.setBit(0); +isBigInteger = x.clearBit(0); +isBigInteger = x.flipBit(0); +x.addTo(x, isBigInteger); +isBigInteger = x.add(x); +isBigInteger = x.subtract(x); +isBigInteger = x.multiply(x); +isBigInteger = x.square(); +isBigInteger = x.divide(x); +isBigInteger = x.remainder(x); +isDivmod = x.divideAndRemainder(x); +x.dMultiply(0); +x.dAddOffset(0, 0); +isBigInteger = x.pow(0); +x.multiplyLowerTo(x, 0, isBigInteger); +x.multiplyUpperTo(x, 0, isBigInteger); +isBigInteger = x.modPow(x, x); +isBigInteger = x.gcd(x); +isNumber = x.modInt(0); +isBigInteger = x.modInverse(x); +isBoolean = x.isProbablePrime(0); +isBoolean = x.millerRabin(0); diff --git a/jsbn/jsbn.d.ts b/jsbn/jsbn.d.ts new file mode 100644 index 000000000..bd75bd876 --- /dev/null +++ b/jsbn/jsbn.d.ts @@ -0,0 +1,250 @@ +// Type definitions for jsbn v1.2 +// Project: http://www-cs-students.stanford.edu/%7Etjw/jsbn/ +// Definitions by: Eugene Chernyshov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module jsbn { + + interface RandomGenerator { + nextBytes(bytes: number[]): void; + } + + export class BigInteger { + constructor(a: number, c: RandomGenerator); + constructor(a: number, b: number, c: RandomGenerator); + constructor(a: string, b?: number); + constructor(a: number[], b?: number); + constructor(a: BigInteger); + + s: number; + t: number; + data: number[]; // forge specific + + DB: number; + DM: number; + DV: number; + + FV: number; + F1: number; + F2: number; + + // am: Compute w_j += (x*this_i), propagate carries, + am(i: number, x: number, w: BigInteger, j: number, c: number, n: number): number; + + // (protected) copy this to r + copyTo(r: BigInteger): void; + + // (protected) set from integer value x, -DV <= x < DV + fromInt(x: number): void; + + // (protected) set from string and radix + fromString(x: string, b: number): void; + + // (protected) clamp off excess high words + clamp(): void; + + // (public) return string representation in given radix + toString(b?: number): string; + + // (public) -this + negate(): BigInteger; + + // (public) |this| + abs(): BigInteger; + + // (public) return + if this > a, - if this < a, 0 if equal + compareTo(a: BigInteger): number; + + // (public) return the number of bits in "this" + bitLength(): number; + + // (protected) r = this << n*DB + dlShiftTo(n: number, r: BigInteger): void; + + // (protected) r = this >> n*DB + drShiftTo(n: number, r: BigInteger): void; + + // (protected) r = this << n + lShiftTo(n: number, r: BigInteger): void; + + // (protected) r = this >> n + rShiftTo(n: number, r: BigInteger): void; + + // (protected) r = this - a + subTo(a: BigInteger, r: BigInteger): void; + + // (protected) r = this * a, r != this,a (HAC 14.12) + multiplyTo(a: BigInteger, r: BigInteger): void; + + // (protected) r = this^2, r != this (HAC 14.16) + squareTo(r: BigInteger): void; + + // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) + // r != q, this != m. q or r may be null. + divRemTo(m: BigInteger, q: BigInteger, r: BigInteger): void; + + // (public) this mod a + mod(a: BigInteger): BigInteger; + + // (protected) return "-1/this % 2^DB"; useful for Mont. reduction + invDigit(): number; + + // (protected) true iff this is even + isEven(): boolean; + + // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) + exp(e: number, z: Reduction): BigInteger; + + // (public) this^e % m, 0 <= e < 2^32 + modPowInt(e: number, m: BigInteger): BigInteger; + + // (public) + clone(): BigInteger; + + // (public) return value as integer + intValue(): number; + + // (public) return value as byte + byteValue(): number; + + // (public) return value as short (assumes DB>=16) + shortValue(): number; + + // (protected) return x s.t. r^x < DV + chunkSize(r: number): number; + + // (public) 0 if this == 0, 1 if this > 0 + signum(): number; + + // (protected) convert to radix string + toRadix(b: number): string; + + // (protected) convert from radix string + fromRadix(s: string, b: number): void; + + // (protected) alternate constructor + fromNumber(a: number, b?: number, c?: number): void; + + // (public) convert to bigendian byte array + toByteArray(): number[]; + + equals(a: BigInteger): boolean; + + min(a: BigInteger): BigInteger; + + max(a: BigInteger): BigInteger; + + // (protected) r = this op a (bitwise) + bitwiseTo(a: BigInteger, op: (x: number, y: number) => number, r: BigInteger): void; + + // (public) this & a + and(a: BigInteger): BigInteger; + + // (public) this | a + or(a: BigInteger): BigInteger; + + // (public) this ^ a + xor(a: BigInteger): BigInteger; + + // (public) this & ~a + andNot(a: BigInteger): BigInteger; + + // (public) ~this + not(): BigInteger; + + // (public) this << n + shiftLeft(n: number): BigInteger; + + // (public) this >> n + shiftRight(n: number): BigInteger; + + // (public) returns index of lowest 1-bit (or -1 if none) + getLowestSetBit(): number; + + // (public) return number of set bits + bitCount(): number; + + // (public) true iff nth bit is set + testBit(n: number): boolean; + + // (protected) this op (1< number): BigInteger; + + // (protected) this op (1<= 0, 1 < n < DV + dMultiply(n: number): void; + + // (protected) this += n << w words, this >= 0 + dAddOffset(n: number, w: number): void; + + // (public) this^e + pow(e: number): BigInteger; + + // (protected) r = lower n words of "this * a", a.t <= n + multiplyLowerTo(a: BigInteger, n: number, r: BigInteger): void; + + // (protected) r = "this * a" without lower n words, n > 0 + multiplyUpperTo(a: BigInteger, n: number, r: BigInteger): void; + + // (public) this^e % m (HAC 14.85) + modPow(e: BigInteger, m: BigInteger): BigInteger; + + // (public) gcd(this,a) (HAC 14.54) + gcd(a: BigInteger): BigInteger; + + // (protected) this % n, n < 2^26 + modInt(n: number): number; + + // (public) 1/this % m (HAC 14.61) + modInverse(m: BigInteger): BigInteger; + + // (public) test primality with certainty >= 1-.5^t + isProbablePrime(t: number): boolean; + + // (protected) true if probably prime (HAC 4.24, Miller-Rabin) + millerRabin(t: number): boolean; + + static ZERO: BigInteger; + static ONE: BigInteger; + } + + interface Reduction { + convert(x: BigInteger): BigInteger; + revert(x: BigInteger): BigInteger; + reduce(x: BigInteger): void; + mulTo(x: BigInteger, y: BigInteger, r: BigInteger): void; + sqrTo(x: BigInteger, r: BigInteger): void; + } +} \ No newline at end of file From 4ea6c8e68519c2f92d4c7fa200bfafb07194d89e Mon Sep 17 00:00:00 2001 From: San Chen Date: Tue, 5 Aug 2014 09:34:14 +0800 Subject: [PATCH 24/33] needle definitions and tests added --- needle/needle-tests.ts | 112 +++++++++++++++++++++++++++++++++++++---- needle/needle.d.ts | 80 +++++++++++++++++++++++++++-- 2 files changed, 178 insertions(+), 14 deletions(-) diff --git a/needle/needle-tests.ts b/needle/needle-tests.ts index 70c88933c..7283aeaa1 100644 --- a/needle/needle-tests.ts +++ b/needle/needle-tests.ts @@ -2,13 +2,107 @@ import needle = require("needle"); -var url = ""; -var options = {}; -var callback = (err, resp) => {}; +function Usage() { + // using callback + needle.get('http://ifconfig.me/all.json', function (error, response) { + if (!error) + console.log(response.body.ip_addr); // JSON decoding magic. :) + }); -needle.head(url, options, callback); -needle.get(url, options, callback); -needle.post(url, data, options, callback); -needle.put(url, data, options, callback); -needle.delete(url, data, options, callback); -needle.request(method, url, data, options, callback); + // using streams + var out; // = fs.createWriteStream('logo.png'); + needle.get('https://google.com/images/logo.png').pipe(out); +} + +function ResponsePipeline() { + needle.get('http://stackoverflow.com/feeds', { compressed: true }, function (err, resp) { + console.log(resp.body); // this little guy won't be a Gzipped binary blob + // but a nice object containing all the latest entries + }); + + var options = { + compressed: true, + follow: true, + rejectUnauthorized: true + }; + + // in this case, we'll ask Needle to follow redirects (disabled by default), + // but also to verify their SSL certificates when connecting. + var stream = needle.get('https://backend.server.com/everything.html', options); + + stream.on('readable', function () { + var data; + while (data = this.read()) { + console.log(data.toString()); + } + }); +} + +function API_head() { + var options = { + timeout: 5000 // if we don't get a response in 5 seconds, boom. + }; + + needle.head('https://my.backend.server.com', function (err, resp) { + if (err) { + console.log('Shoot! Something is wrong: ' + err.message); + } + else { + console.log('Yup, still alive.'); + } + }); +} + +function API_get() { + needle.get('google.com/search?q=syd+barrett', function (err, resp) { + // if no http:// is found, Needle will automagically prepend it. + }); +} + +function API_post() { + var options = { + headers: { 'X-Custom-Header': 'Bumbaway atuna' } + }; + + needle.post('https://my.app.com/endpoint', 'foo=bar', options, function (err, resp) { + // you can pass params as a string or as an object. + }); +} + +function API_put() { + var nested = { + params: { + are: { + also: 'supported' + } + } + }; + + needle.put('https://api.app.com/v2', nested, function (err, resp) { + console.log('Got ' + resp.bytes + ' bytes.') // another nice treat from this handsome fella. + }); +} + +function API_delete() { + var options = { + username: 'fidelio', + password: 'x' + }; + + needle.delete('https://api.app.com/messages/123', null, options, function (err, resp) { + // in this case, data may be null, but you need to explicity pass it. + }); +} + +function API_request() { + var data = { + q: 'a very smart query', + page: 2, + format: 'json' + }; + + needle.request('get', 'forum.com/search', data, function (err, resp) { + if (!err && resp.statusCode == 200) + console.log(resp.body); // here you go, mister. + }); +} diff --git a/needle/needle.d.ts b/needle/needle.d.ts index 732f5a059..f4c20408f 100644 --- a/needle/needle.d.ts +++ b/needle/needle.d.ts @@ -3,14 +3,84 @@ // Definitions by: San Chen // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface INeedle { - head(url: string): IReadableStream; - head(url: string, callback?: Function): IReadableStream; - head(url: string, options?: any, callback?: Function): IReadableStream; +/// +declare module Needle { + + interface Callback { + (error: Error, response: any, body: any): void; + } + + interface RequestOptions { + timeout?: number; + follow?: any; // number | string + multipart?: boolean; + proxy?: string; + agent?: string; + headers?: any; + auth?: string; // auto | digest | basic (default) + json?: boolean; + } + + interface ResponseOptions { + decode?: boolean; + parse?: boolean; + output?: any; + } + + interface HttpHeaderOptions { + compressed?: boolean; + username?: string; + password?: string; + accept?: string; + connection?: string; + user_agent?: string; + } + + interface TLSOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: any; + rejectUnauthorized?: boolean; + secureProtocol?: any; + } + + interface NeedleOptions extends RequestOptions, ResponseOptions, HttpHeaderOptions, TLSOptions { + } + + interface NeedleStatic { + defaults(options?: any): void; + + head(url: string): ReadableStream; + head(url: string, callback?: Callback): ReadableStream; + head(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; + + get(url: string): ReadableStream; + get(url: string, callback?: Callback): ReadableStream; + get(url: string, options?: RequestOptions, callback?: Callback): ReadableStream; + + post(url: string, data: any): ReadableStream; + post(url: string, data: any, callback?: Callback): ReadableStream; + post(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + put(url: string, data: any): ReadableStream; + put(url: string, data: any, callback?: Callback): ReadableStream; + put(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + delete(url: string, data: any): ReadableStream; + delete(url: string, data: any, callback?: Callback): ReadableStream; + delete(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + + request(method: string, url: string, data: any): ReadableStream; + request(method: string, url: string, data: any, callback?: Callback): ReadableStream; + request(method: string, url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream; + } } declare module "needle" { - var needle: INeedle; + var needle: Needle.NeedleStatic; export = needle; } From 53558dd1643bc3a2939a51446c06e5f8c9f2d7a8 Mon Sep 17 00:00:00 2001 From: MIZUNE Pine Date: Tue, 5 Aug 2014 11:15:55 +0900 Subject: [PATCH 25/33] Add http-string-parser --- CONTRIBUTORS.md | 1 + http-string-parser/http-string-parser-test.ts | 42 +++++++++++++++++++ http-string-parser/http-string-parser.d.ts | 38 +++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 http-string-parser/http-string-parser-test.ts create mode 100644 http-string-parser/http-string-parser.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index aafef048d..5da07cb74 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -125,6 +125,7 @@ All definitions files include a header with the author and editors, so at some p * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) +* [http-string-parser](https://github.com/apiaryio/http-string-parser) (by [MIZUNE Pine](https://github.com/pine613)) * [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) diff --git a/http-string-parser/http-string-parser-test.ts b/http-string-parser/http-string-parser-test.ts new file mode 100644 index 000000000..9c4116e5d --- /dev/null +++ b/http-string-parser/http-string-parser-test.ts @@ -0,0 +1,42 @@ +/// + +import parser = require("http-string-parser"); + +function test_request(): void { + var result = parser.parseRequest("HTTP/1.1 GET /\r\nHost: www.example.com\r\n\r\n"); + + var body: string = result.body; + var headers: { [key: string]: string } = result.headers; + var method: string = result.method; + var uri: string = result.uri; +} + +function test_response(): void { + var response = parser.parseResponse("HTTP/1.1 200 OK\r\n\r\n"); + + var body: string = response.body; + var headers: { [key: string]: string } = response.headers; + var statusCode: string = response.statusCode; + var statusMessage: string = response.statusMessage; +} + +function test_requestLine(): void { + var result = parser.parseRequestLine("HTTP/1.1 GET /"); + + var method: string = result.method; + var protocol: string = result.protocol; + var uri: string = result.uri; +} + +function test_statusLine(): void { + var result = parser.parseStatusLine("HTTP/1.1 200 OK"); + + var protocol: string = result.protocol; + var statusCode: string = result.statusCode; + var statusMessage: string = result.statusMessage; +} + +function test_headers(): void { + var result: { [key: string]: string } = + parser.parseHeaders("Content-Type: text/html; charset=utf-8\r\nContent-Length: 256\r\n"); +} \ No newline at end of file diff --git a/http-string-parser/http-string-parser.d.ts b/http-string-parser/http-string-parser.d.ts new file mode 100644 index 000000000..893457279 --- /dev/null +++ b/http-string-parser/http-string-parser.d.ts @@ -0,0 +1,38 @@ +// Type definitions for Backbone v0.9.10 +// Project: https://github.com/apiaryio/http-string-parser +// Definitions by: MIZUNE Pine +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "http-string-parser" { + interface ParseRequestResult { + method: string; + uri: string; + headers: { [key: string]: string }; + body: string; + } + + interface ParseResponseResult { + statusCode: string; + statusMessage: string; + headers: { [key: string]: string }; + body: string; + } + + interface ParseRequestLineResult { + method: string; + uri: string; + protocol: string; + } + + interface ParseStatusLineResult { + protocol: string; + statusCode: string; + statusMessage: string; + } + + export function parseRequest(requestString: string): ParseRequestResult; + export function parseResponse(responseString: string): ParseResponseResult; + export function parseRequestLine(requestLineString: string): ParseRequestLineResult; + export function parseStatusLine(statusLine: string): ParseStatusLineResult; + export function parseHeaders(headerLines: string): { [key: string]: string }; +} From e0d5a27525df14b9ba0486f326da549491f026c1 Mon Sep 17 00:00:00 2001 From: MIZUNE Pine Date: Tue, 5 Aug 2014 11:20:19 +0900 Subject: [PATCH 26/33] Fix header --- http-string-parser/http-string-parser.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-string-parser/http-string-parser.d.ts b/http-string-parser/http-string-parser.d.ts index 893457279..4239cd9df 100644 --- a/http-string-parser/http-string-parser.d.ts +++ b/http-string-parser/http-string-parser.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Backbone v0.9.10 +// Type definitions for http-string-parser // Project: https://github.com/apiaryio/http-string-parser // Definitions by: MIZUNE Pine // Definitions: https://github.com/borisyankov/DefinitelyTyped From a77c6b79f52a74bc0ff1810215d5b32e9d65a06d Mon Sep 17 00:00:00 2001 From: San Chen Date: Tue, 5 Aug 2014 11:06:19 +0800 Subject: [PATCH 27/33] tests passed --- needle/needle-tests.ts | 4 ++-- needle/needle.d.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/needle/needle-tests.ts b/needle/needle-tests.ts index 7283aeaa1..24d9701b5 100644 --- a/needle/needle-tests.ts +++ b/needle/needle-tests.ts @@ -10,7 +10,7 @@ function Usage() { }); // using streams - var out; // = fs.createWriteStream('logo.png'); + var out: any; // = fs.createWriteStream('logo.png'); needle.get('https://google.com/images/logo.png').pipe(out); } @@ -31,7 +31,7 @@ function ResponsePipeline() { var stream = needle.get('https://backend.server.com/everything.html', options); stream.on('readable', function () { - var data; + var data: any; while (data = this.read()) { console.log(data.toString()); } diff --git a/needle/needle.d.ts b/needle/needle.d.ts index f4c20408f..741cf5fe3 100644 --- a/needle/needle.d.ts +++ b/needle/needle.d.ts @@ -6,6 +6,8 @@ /// declare module Needle { + interface ReadableStream extends NodeJS.ReadableStream { + } interface Callback { (error: Error, response: any, body: any): void; From 982f57d1266842ef4554f639b6adf379c320f8e1 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 5 Aug 2014 13:10:10 +0200 Subject: [PATCH 28/33] Phonegap: Fixed Filesystem api --- phonegap/phonegap.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index 37585887b..7d744346a 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -367,7 +367,7 @@ interface FileUploadResult { interface Flags { create: boolean; - exclusive: boolean; + exclusive?: boolean; } /* From 1ba83dded25175aa1239dd6ad0d6e0c81a3571ab Mon Sep 17 00:00:00 2001 From: Nickolas Westman Date: Tue, 5 Aug 2014 11:43:05 -0700 Subject: [PATCH 29/33] Update underscore.d.ts Template return values not correctly typed - if data is passed it will return a string (no partial templating in underscore) --- underscore/underscore.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 7d9c84f82..9736c2879 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1472,8 +1472,9 @@ interface UnderscoreStatic { * @param settings Settings to use while compiling. * @return Returns the compiled Underscore HTML template. **/ - template(templateString: string, data?: any, settings?: _.TemplateSettings): (...data: any[]) => string; - + template(templateString: string): (...data: any[]) => string; + template(templateString: string, data: any, settings?: _.TemplateSettings): string; + /** * By default, Underscore uses ERB-style template delimiters, change the * following template settings to use alternative delimiters. From 0864d50b8c02b79e8a8f247fa671ba6170773fa5 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 6 Aug 2014 10:35:48 +0200 Subject: [PATCH 30/33] Phonegap: Added StatusBar plugin interface --- phonegap/phonegap.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index 7d744346a..566594c51 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -575,6 +575,21 @@ interface LocalStorage { } */ +interface StatusBar { + isVisible: boolean; + + overlaysWebView(doOverlay: boolean): void; + styleDefault(): void; + styleLightContent(): void; + styleBlackTranslucent(): void; + styleBlackOpaque(): void; + backgroundColorByName(colorname: string): void; + backgroundColorByHexString(hexString: string): void; + hide(): void; + show(): void; +} +declare var StatusBar: StatusBar; + interface /*PhoneGapNavigator extends*/ Navigator { accelerometer: Accelerometer; camera: Camera; From 62aebaa52148114b7c6be270c034bf1166389915 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 6 Aug 2014 11:06:12 +0200 Subject: [PATCH 31/33] jQuery: Remove JQueryDeferred.state method because it is already defined in JQueryPromise --- jquery/jquery.d.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e40110c16..1884180fb 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1,6 +1,6 @@ // Type definitions for jQuery 1.10.x / 2.0.x // Project: http://jquery.com/ -// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton , Diullei Gomes , Tass Iliopoulos , Jason Swearingen , Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton , Diullei Gomes , Tass Iliopoulos , Jason Swearingen , Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly , Dick van den Brink // Definitions: https://github.com/borisyankov/DefinitelyTyped /* ***************************************************************************** @@ -525,10 +525,6 @@ interface JQueryDeferred extends JQueryPromise { * @param args An optional array of arguments that are passed to the doneCallbacks. */ resolveWith(context: any, ...args: any[]): JQueryDeferred; - /** - * Determine the current state of a Deferred object. - */ - state(): string; /** * Return a Deferred's Promise object. From 3583fdd36d63bd95fdf28ca702ed637ad530e0dc Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 6 Aug 2014 11:12:10 +0200 Subject: [PATCH 32/33] Added DickvdBrink as an author --- phonegap/phonegap.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index 566594c51..17aeb1ff0 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -1,6 +1,6 @@ // Type definitions for PhoneGap 2.3 // Project: http://phonegap.com -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov , Dick van den Brink // Definitions: https://github.com/borisyankov/DefinitelyTyped interface GeolocationError { From 5f30d6961a2e7db0f1045acbcfcb3ca3d98f3171 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Wed, 6 Aug 2014 09:52:35 +0200 Subject: [PATCH 33/33] Phonegap: Added Keyboard plugin --- phonegap/phonegap.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index 17aeb1ff0..23a9babbe 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -590,6 +590,21 @@ interface StatusBar { } declare var StatusBar: StatusBar; +interface Keyboard { + automaticScrollToTopOnHiding: boolean; + isVisible: boolean; + + onshow: Function; + onhide: Function; + onshowing: Function; + onhiding: Function; + + disableScrollingInShrinkView(disable: boolean): void; + hideFormAccessoryBar(hide: boolean): void; + shrinkView(shrink: boolean): void; +} +declare var Keyboard: Keyboard; + interface /*PhoneGapNavigator extends*/ Navigator { accelerometer: Accelerometer; camera: Camera;