Merge remote-tracking branch 'DefinitelyTyped/master'

This commit is contained in:
Wang Zishi
2015-12-18 13:57:33 +08:00
59 changed files with 4381 additions and 639 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angulartics v0.19.2
// Type definitions for Angulartics v0.20.2
// Project: http://luisfarzati.github.io/angulartics/
// Definitions by: Steven Fan <https://github.com/stevenfan>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -21,6 +21,7 @@ declare module angulartics {
interface IAnalyticsServiceProvider extends angular.IServiceProvider {
virtualPageviews(value: boolean): void;
excludeRoutes(value: string[]): void;
firstPageview(value: boolean): void;
withBase(value: boolean): void;
withAutoBase(value: boolean): void;
+54
View File
@@ -0,0 +1,54 @@
/// <reference path="./bcryptjs.d.ts"/>
import bcryptjs = require("bcryptjs");
let str: string;
let num: number;
let bool: boolean;
str = bcryptjs.genSaltSync();
str = bcryptjs.genSaltSync(10);
bcryptjs.genSalt((err: Error, salt: string) => {
str = salt;
});
bcryptjs.genSalt(10, (err: Error, salt: string) => {
str = salt;
});
str = bcryptjs.hashSync("string");
str = bcryptjs.hashSync("string", 10);
str = bcryptjs.hashSync("string", "salt");
bcryptjs.hash("string", 10, (err: Error, hash: string) => {
str = hash;
});
bcryptjs.hash("string", 10, (err: Error, hash: string) => {
str = hash;
}, (percent: number) => {
num = percent;
});
bcryptjs.hash("string", "salt", (err: Error, hash: string) => {
str = hash;
});
bcryptjs.hash("string", "salt", (err: Error, hash: string) => {
str = hash;
}, (percent: number) => {
num = percent;
});
bool = bcryptjs.compareSync("string1", "string2");
bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => {
bool = success;
});
bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => {
bool = success;
}, (percent: number) => {
num = percent;
});
num = bcryptjs.getRounds("string");
str = bcryptjs.getSalt("string");
+82
View File
@@ -0,0 +1,82 @@
// Type definitions for bcryptjs v2.3.0
// Project: https://github.com/dcodeIO/bcrypt.js
// Definitions by: Joshua Filby <https://github.com/Joshua-F/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "bcryptjs" {
/**
* Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available.
* Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly!
* @param random Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values.
*/
export function setRandomFallback(random: (random: number) => number[]): void;
/**
* Synchronously generates a salt.
* @param rounds Number of rounds to use, defaults to 10 if omitted
* @return Resulting salt
*/
export function genSaltSync(rounds?: number): string;
/**
* Asynchronously generates a salt.
* @param callback Callback receiving the error, if any, and the resulting salt
*/
export function genSalt(callback: (err: Error, salt: string) => void): void;
/**
* Asynchronously generates a salt.
* @param rounds Number of rounds to use, defaults to 10 if omitted
* @param callback Callback receiving the error, if any, and the resulting salt
*/
export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void;
/**
* Synchronously generates a hash for the given string.
* @param s String to hash
* @param salt Salt length to generate or salt to use, default to 10
* @return Resulting hash
*/
export function hashSync(s: string, salt?: number | string): string;
/**
* Asynchronously generates a hash for the given string.
* @param s String to hash
* @param salt Salt length to generate or salt to use
* @param callback Callback receiving the error, if any, and the resulting hash
* @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
*/
export function hash(s: string, salt: number | string, callback: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void;
/**
* Synchronously tests a string against a hash.
* @param s String to compare
* @param hash Hash to test against
* @return true if matching, otherwise false
*/
export function compareSync(s: string, hash: string): boolean;
/**
* Asynchronously compares the given data against the given hash.
* @param s Data to compare
* @param hash Data to be compared to
* @param callback Callback receiving the error, if any, otherwise the result
* @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
*/
export function compare(s: string, hash: string, callback: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void;
/**
* Gets the number of rounds used to encrypt the specified hash.
* @param hash Hash to extract the used number of rounds from
* @return Number of rounds used
*/
export function getRounds(hash: string): number;
/**
* Gets the salt portion from a hash. Does not validate the hash.
* @param hash Hash to extract the salt from
* @return Extracted salt part
*/
export function getSalt(hash: string): string;
}
+170
View File
@@ -0,0 +1,170 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="blue-tape.d.ts" />
import tape = require('blue-tape');
import P = require('bluebird');
var name: string;
var cb: tape.TestCase;
var opts: tape.TestOptions;
var t: tape.Test;
tape(cb);
tape(name, cb);
tape(opts, cb);
tape(name, opts, cb);
tape(name, (test: tape.Test) => {
t = test;
});
tape.skip(name, cb);
tape.only(name, cb);
var sopts: tape.StreamOptions;
var rs: NodeJS.ReadableStream;
rs = tape.createStream();
rs = tape.createStream(sopts);
var htest: typeof tape;
htest = tape.createHarness();
tape(name, (test: tape.Test) => {
var num: number;
var ms: number;
var value: any;
var actual: any;
var expected: any;
var err: any;
var fn = function() {};
var msg: string;
var exceptionExpected: RegExp | (() => void);
test.plan(num);
test.end();
test.end(err);
test.fail(msg);
test.pass(msg);
test.timeoutAfter(ms);
test.skip(msg);
test.ok(value);
test.ok(value, msg);
test.true(value);
test.true(value, msg);
test.assert(value);
test.assert(value, msg);
test.notOk(value);
test.notOk(value, msg);
test.false(value);
test.false(value, msg);
test.notok(value);
test.notok(value, msg);
test.error(err, msg);
test.ifError(err, msg);
test.ifErr(err, msg);
test.iferror(err, msg);
test.equal(actual, expected);
test.equal(actual, expected, msg);
test.equals(actual, expected);
test.equals(actual, expected, msg);
test.isEqual(actual, expected);
test.isEqual(actual, expected, msg);
test.is(actual, expected);
test.is(actual, expected, msg);
test.strictEqual(actual, expected);
test.strictEqual(actual, expected, msg);
test.strictEquals(actual, expected);
test.strictEquals(actual, expected, msg);
test.notEqual(actual, expected);
test.notEqual(actual, expected, msg);
test.notEquals(actual, expected);
test.notEquals(actual, expected, msg);
test.notStrictEqual(actual, expected);
test.notStrictEqual(actual, expected, msg);
test.notStrictEquals(actual, expected);
test.notStrictEquals(actual, expected, msg);
test.isNotEqual(actual, expected);
test.isNotEqual(actual, expected, msg);
test.isNot(actual, expected);
test.isNot(actual, expected, msg);
test.not(actual, expected);
test.not(actual, expected, msg);
test.doesNotEqual(actual, expected);
test.doesNotEqual(actual, expected, msg);
test.isInequal(actual, expected);
test.isInequal(actual, expected, msg);
test.deepEqual(actual, expected);
test.deepEqual(actual, expected, msg);
test.deepEquals(actual, expected);
test.deepEquals(actual, expected, msg);
test.isEquivalent(actual, expected);
test.isEquivalent(actual, expected, msg);
test.same(actual, expected);
test.same(actual, expected, msg);
test.notDeepEqual(actual, expected);
test.notDeepEqual(actual, expected, msg);
test.notEquivalent(actual, expected);
test.notEquivalent(actual, expected, msg);
test.notDeeply(actual, expected);
test.notDeeply(actual, expected, msg);
test.notSame(actual, expected);
test.notSame(actual, expected, msg);
test.isNotDeepEqual(actual, expected);
test.isNotDeepEqual(actual, expected, msg);
test.isNotDeeply(actual, expected);
test.isNotDeeply(actual, expected, msg);
test.isNotEquivalent(actual, expected);
test.isNotEquivalent(actual, expected, msg);
test.isInequivalent(actual, expected);
test.isInequivalent(actual, expected, msg);
test.deepLooseEqual(actual, expected);
test.deepLooseEqual(actual, expected, msg);
test.looseEqual(actual, expected);
test.looseEqual(actual, expected, msg);
test.looseEquals(actual, expected);
test.looseEquals(actual, expected, msg);
test.notDeepLooseEqual(actual, expected);
test.notDeepLooseEqual(actual, expected, msg);
test.notLooseEqual(actual, expected);
test.notLooseEqual(actual, expected, msg);
test.notLooseEquals(actual, expected);
test.notLooseEquals(actual, expected, msg);
test.throws(fn);
test.throws(fn, msg);
test.throws(fn, exceptionExpected);
test.throws(fn, exceptionExpected, msg);
test.doesNotThrow(fn);
test.doesNotThrow(fn, msg);
test.doesNotThrow(fn, exceptionExpected);
test.doesNotThrow(fn, exceptionExpected, msg);
test.test(name, (st) => {
t = st;
});
test.comment(msg);
});
tape('simple delay', (test) => P.delay(1));
tape('nested tests with promises', function(test) {
test.test('delay1', () => P.delay(1) );
test.test('delay2', () => P.delay(1) );
});
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for blue-tape v0.1.11
// Project: https://github.com/spion/blue-tape
// Definitions by: Haoqun Jiang <https://github.com/sodatea>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../tape/tape.d.ts" />
declare module 'blue-tape' {
import tape = require('tape');
export = tape;
}
-1
View File
@@ -97,4 +97,3 @@ class Photo extends bookshelf.Model<Photo> {
return this.morphTo('imageable', Site, Post);
}
}
+33 -33
View File
@@ -11,7 +11,7 @@ declare module 'bookshelf' {
import knex = require('knex');
import Promise = require('bluebird');
import Lodash = require('lodash');
interface Bookshelf extends Bookshelf.Events<any> {
VERSION : string;
knex : knex;
@@ -20,9 +20,9 @@ declare module 'bookshelf' {
transaction<T>(callback : (transaction : knex.Transaction) => T) : Promise<T>;
}
function Bookshelf(knex : knex) : Bookshelf;
namespace Bookshelf {
abstract class Events<T> {
on(event? : string, callback? : EventFunction<T>, context? : any) : void;
@@ -31,20 +31,20 @@ declare module 'bookshelf' {
triggerThen(name : string, ...args : any[]) : Promise<any>;
once(event : string, callback : EventFunction<T>, context? : any) : void;
}
interface IModelBase {
/** Should be declared as a getter instead of a plain property. */
hasTimestamps? : boolean|string[];
/** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
tableName? : string;
}
abstract class ModelBase<T extends Model<any>> extends Events<T|Collection<T>> implements IModelBase {
/** If overriding, must use a getter instead of a plain property. */
idAttribute : string;
constructor(attributes? : any, options? : ModelOptions);
clear() : T;
clone() : T;
escape(attribute : string) : string;
@@ -63,7 +63,7 @@ declare module 'bookshelf' {
timestamp(options? : TimestampOptions) : any;
toJSON(options? : SerializeOptions) : any;
unset(attribute : string) : T;
// lodash methods
invert<R extends {}>() : R;
keys() : string[];
@@ -74,7 +74,7 @@ declare module 'bookshelf' {
pick<R extends {}>(...attributes : string[]) : R;
values() : any[];
}
class Model<T extends Model<any>> extends ModelBase<T> {
static collection<T extends Model<any>>(models? : T[], options? : CollectionOptions<T>) : Collection<T>;
static count(column? : string, options? : SyncOptions) : Promise<number>;
@@ -83,7 +83,7 @@ declare module 'bookshelf' {
static fetchAll<T extends Model<any>>() : Promise<Collection<T>>;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes? : any, options? : ModelOptions) : T;
belongsTo<R extends Model<any>>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
belongsToMany<R extends Model<any>>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection<R>;
count(column? : string, options? : SyncOptions) : Promise<number>;
@@ -109,7 +109,7 @@ declare module 'bookshelf' {
where(properties : {[key : string] : any}) : T;
where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T;
}
abstract class CollectionBase<T extends Model<any>> extends Events<T> {
add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection<T>;
at(index : number) : T;
@@ -133,7 +133,7 @@ declare module 'bookshelf' {
toJSON(options? : SerializeOptions) : any;
unshift(model : any, options? : CollectionAddOptions) : void;
where(match : {[key : string] : any}, firstOnly : boolean) : T|Collection<T>;
// lodash methods
all(predicate? : Lodash.ListIterator<T, boolean>|Lodash.DictionaryIterator<T, boolean>|string, thisArg? : any) : boolean;
all<R extends {}>(predicate? : R) : boolean;
@@ -200,13 +200,13 @@ declare module 'bookshelf' {
toArray() : T[];
without(...values : any[]) : T[];
}
class Collection<T extends Model<any>> extends CollectionBase<T> {
/** @deprecated use Typescript classes */
static extend<T>(prototypeProperties? : any, classProperties? : any) : Function;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes? : any, options? : ModelOptions) : T;
attach(ids : any[], options? : SyncOptions) : Promise<Collection<T>>;
count(column? : string, options? : SyncOptions) : Promise<number>;
create(model : {[key : string] : any}, options? : CollectionCreateOptions) : Promise<T>;
@@ -222,92 +222,92 @@ declare module 'bookshelf' {
updatePivot(attributes : any, options? : PivotOptions) : Promise<number>;
withPivot(columns : string[]) : Collection<T>;
}
interface ModelOptions {
tableName? : string;
hasTimestamps? : boolean;
parse? : boolean;
}
interface LoadOptions extends SyncOptions {
withRelated: string|any|any[];
}
interface FetchOptions extends SyncOptions {
require? : boolean;
columns? : string|string[];
withRelated? : string|any|any[];
}
interface FetchAllOptions extends SyncOptions {
require? : boolean;
}
interface SaveOptions extends SyncOptions {
method? : string;
defaults? : string;
patch? : boolean;
require? : boolean;
}
interface SerializeOptions {
shallow? : boolean;
omitPivot? : boolean;
}
interface SetOptions {
unset? : boolean;
}
interface TimestampOptions {
method? : string;
}
interface SyncOptions {
transacting? : knex.Transaction;
debug? : boolean;
}
interface CollectionOptions<T> {
comparator? : boolean|string|((a : T, b : T) => number);
}
interface CollectionAddOptions extends EventOptions {
at? : number;
merge? : boolean;
}
interface CollectionFetchOptions {
require? : boolean;
withRelated? : string|string[];
}
interface CollectionFetchOneOptions {
require? : boolean;
columns? : string|string[];
}
interface CollectionSetOptions extends EventOptions {
add? : boolean;
remove? : boolean;
merge?: boolean;
}
interface PivotOptions {
query? : Function|any;
require? : boolean;
}
interface EventOptions {
silent? : boolean;
}
interface EventFunction<T> {
(model: T, attrs: any, options: any) : Promise<any>|void;
}
interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions {}
}
export = Bookshelf;
}
+3 -3
View File
@@ -2646,13 +2646,13 @@ declare module chrome.extension {
* Parameter request: The request sent by the calling script.
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response.
*/
addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: () => void) => void): void;
addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void;
/**
* @param callback The callback parameter should be a function that looks like this:
* function(runtime.MessageSender sender, function sendResponse) {...};
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response.
*/
addListener(callback: (sender: runtime.MessageSender, sendResponse: () => void) => void): void;
addListener(callback: (sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void;
}
/**
@@ -5553,7 +5553,7 @@ declare module chrome.runtime {
* Optional parameter message: The message sent by the calling script.
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one onMessage listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called).
*/
addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
addListener(callback: (message: any, sender: MessageSender, sendResponse: (response: any) => void) => void): void;
}
interface ExtensionConnectEvent extends chrome.events.Event {
+185
View File
@@ -0,0 +1,185 @@
/// <reference path="./cradle.d.ts" />
import cradle = require("cradle");
cradle.setup({
host: 'living-room.couch',
cache: true,
raw: false,
forceSave: true
});
const connection = new cradle.Connection();
const connection2 = new(cradle.Connection);
const connection3 = new(cradle.Connection)('173.45.66.92');
connection.databases(function(error, response) {});
connection.config(function(error, response) {});
connection.databases(function(error, response) {});
connection.info(function(error, response) {});
connection.stats(function(error, response) {});
connection.activeTasks(function(error, response) {});
connection.uuids(function(error, response) {});
connection.uuids(10, function(error, response) {});
connection.replicate({
source: "database",
target: "targetDatabase"
}, function(error, response) {});
const db = connection.database('starwars');
db.exists(function (error, exists) {
if (error) {
console.log('error', error);
} else if (exists) {
console.log('the force is with you.');
} else {
console.log('database does not exists.');
db.create(function(error){
/* do something if there's an erroror */
/* populate design documents */
});
}
});
db.get<{
name: string;
}>('vader', function (error, doc) {
doc.name; // 'Darth Vader'
});
db.get('luke', function (error, doc) {
doc.prop;
});
db.get(['luke', 'vader'], function (error, doc) {
//
});
db.save('skywalker', {
force: 'light',
name: 'Luke Skywalker'
}, function (error, res) {
if (error) {
// Handle erroror
} else {
// Handle success
}
});
db.save({
force: 'dark', name: 'Darth'
}, function (err, res) {
// Handle response
});
db.save('luke', '1-94B6F82', {
force: 'dark', name: 'Luke'
}, function (err, res) {
// Handle response
});
db.save([
{ name: 'Yoda' },
{ name: 'Han Solo' },
{ name: 'Leia' }
], function (err, res) {
// Handle response
});
db.merge('luke', {jedi: true}, function (err, res) {
// Luke is now a jedi,
// but remains on the dark side of the force.
});
db.view('characters/all', function (err, res) {
res.forEach(function (row: any) {
console.log("%s is on the %s side of the force.", row.name, row.force);
});
});
db.view('characters/all', {group: true, reduce: true} , function (err, res) {
res.forEach(function (row: any) {
console.log("%s is on the %s side of the force.", row.name, row.force);
});
});
db.temporaryView({
map: function (doc: any) {
//
}
}, function (err, res) {
if (err) console.log(err);
console.log(res);
});
db.remove('luke', '1-94B6F82', function (err, res) {
// Handle response
});
db.update('my_designdoc/update_handler_name', 'luke', undefined, { my_param: false }, function (err, res) {
// Handle the response, specified by the update handler
});
db.changes(function (err, list) {
list.forEach(function (change) { console.log(change) });
});
db.changes({ since: 42 }, function (err, list) {
//
});
const feed = db.changes({ since: 42 });
feed.on('change', function (change: any) {
console.log(change);
});
const idAndRevData = {
id: 'luke',
rev: 'my-rev'
};
const attachmentData = {
name: 'fooAttachment.txt',
'Content-Type': 'text/plain',
body: 'Foo document text'
};
db.saveAttachment(idAndRevData, attachmentData, function (err, reply) {
if (err) {
console.dir(err)
return
}
console.dir(reply)
});
db.getAttachment('luke', 'foo.txt', function (err, reply) {
if (err) {
console.dir(err);
return;
}
console.dir(reply);
});
db.removeAttachment('luke', 'foo.txt', function (err, reply) {
if (err) {
console.dir(err);
return;
}
console.dir(reply);
});
db.info(function(error, response) {});
db.all(function(error, response) {});
db.all({
body: {
keys: ['key1', 'key2']
}
}, function(error, response) {});
db.compact(function(error, response) {});
db.compact('design', function(error, response) {});
db.viewCleanup(function(error, response) {});
db.replicate('database', function(error, response) {});
db.replicate('database', {}, function(error, response) {});
+122
View File
@@ -0,0 +1,122 @@
// Type definitions for cradle
// Project: https://github.com/flatiron/cradle
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "cradle" {
interface Options {
host?: string;
hostname?: string;
cache?: boolean;
raw?: boolean;
forceSave?: boolean;
auth?: string | {
username: string;
password: string;
}
ca?: string;
secure?: boolean;
retries?: number;
retryTimeout?: number;
maxSockets?: number;
}
interface Callback {
(error: any, response: any): void;
}
interface ErrorCallback {
(error: any): void;
}
export class Connection {
constructor(uri?: string, port?: number, options?: Options);
database(name: string): Database;
databases(Callback: Callback): void;
config(callback: Callback): void;
info(callback: Callback): void;
stats(callback: Callback): void;
activeTasks(callback: Callback): void;
uuids(callback: Callback): void;
uuids(count: number, callback: Callback): void;
replicate(options: {
source: string | {
url: string;
};
target: string | {
url: string;
};
cancel?: boolean;
continuous?: boolean;
create_target?: boolean;
doc_ids?: string[];
filter?: string;
proxy?: string;
query_params?: any;
}, callback: Callback): void;
}
export interface ChangesOptions {
since: number;
}
export class Database {
name: string;
get(id: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, callback: (error: any, document: T) => void): void;
get(id: string, rev: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, rev: string, callback: (error: any, document: T) => void): void;
get(ids: string[], callback: Callback): void;
save(document: any, callback: Callback): void;
save(id: string, document: any, callback: Callback): void;
save(id: string, revision: string, document: any,
callback: Callback): void;
save<T>(document: T, callback: Callback): void;
save<T>(id: string, document: T, callback: Callback): void;
save<T>(id: string, revision: string, document: T,
callback: Callback): void;
save(documents: any[], callback: Callback): void;
merge(id: string, document: any, callback: Callback): void;
merge<T>(id: string, document: T, callback: Callback): void;
remove(id: string, revision: string, callback: Callback): void;
update(name: string, id: string, queryObject: any, documentBody: any,
callback: Callback): void;
view(name: string, callback: Callback): void;
view(name: string, options: {
group?: boolean;
reduce?: boolean;
key?: string;
startkey?: any;
endkey?: any;
include_docs?: boolean;
limit?: number;
descending?: boolean;
}, callback: Callback): void;
temporaryView(view: any, callback: Callback): void;
create(callback: ErrorCallback): void;
exists(callback: (error: any, exists: boolean) => void): void;
destroy(callback: ErrorCallback): void;
changes(options: ChangesOptions): any;
changes(callback: (error: any, list: any[]) => void): void;
changes(options: ChangesOptions, callback: (error: any,
list: any[]) => void): void;
saveAttachment(idAndRevData: {
id: string;
rev: string;
}, attachmentData: any, callback: Callback): void;
getAttachment(id: string, attachmentName: string,
callback: Callback): void;
removeAttachment(id: string, attachmentName: string,
callback: Callback): void;
info(callback: Callback): void;
all(callback: Callback): void;
all(options: any, callback: Callback): void;
compact(callback: Callback): void;
compact(design: string, callback: Callback): void;
viewCleanup(callback: Callback): void;
replicate(target: string, callback: Callback): void;
replicate(target: string, options: any, callback: Callback): void;
}
export function setup(options: Options): void;
}
+40
View File
@@ -0,0 +1,40 @@
/// <reference path="cucumber.d.ts" />
function StepSample() {
type Callback = cucumber.CallbackStepDefinition;
var step = <cucumber.StepDefinitions>this;
var hook = <cucumber.Hooks>this;
hook.Before(function(scenario, callback){
scenario.isFailed() && callback.pending();
})
hook.Around(function(scenario, runScenario) {
scenario.isFailed() && runScenario(null, function(){
console.log('finish tasks');
});
});
hook.registerHandler('AfterFeatures', function (event, callback) {
callback();
});
step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback:Callback) {
this.visit('https://github.com/cucumber/cucumber-js', callback);
});
step.When(/^I go to the README file$/, function(title:string, callback:Callback) {
callback.pending();
});
step.Then(/^I should see "(.*)" as the page title$/, { timeout:60*1000}, function(title:string, callback:Callback) {
var pageTitle = this.browser.text('title');
if (title === pageTitle) {
callback();
} else {
callback(new Error("Expected to be on page with title " + title));
}
});
}
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for cucumber-js
// Project: https://github.com/cucumber/cucumber-js
// Definitions by: Abraão Alves <https://github.com/abraaoalves>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module cucumber {
export interface CallbackStepDefinition{
pending : () => Thenable<any>;
(errror?:any):void;
}
interface StepDefinitionCode {
(...stepArgs: Array<string |CallbackStepDefinition>): Thenable<any> | any | void;
}
interface StepDefinitionOptions{
timeout?: number;
}
export interface StepDefinitions {
Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
Given(pattern: RegExp | string, code: StepDefinitionCode): void;
When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
When(pattern: RegExp | string, code: StepDefinitionCode): void;
Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
Then(pattern: RegExp | string, code: StepDefinitionCode): void;
setDefaultTimeout(time:number): void;
}
interface HookScenario{
attach(text: string, mimeType?: string, callback?: (err?:any) => void): void;
isFailed() : boolean;
}
interface HookCode {
(scenario: HookScenario, callback?: CallbackStepDefinition): void;
}
interface AroundCode{
(scenario: HookScenario, runScenario?: (error:string, callback?:Function)=>void): void;
}
export interface Hooks {
Before(code: HookCode): void;
After(code: HookCode): void;
Around(code: AroundCode):void;
setDefaultTimeout(time:number): void;
registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void;
}
}
declare module 'cucumber'{
export = cucumber;
}
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="debounce.d.ts" />
import debounce from "debounce";
const doThings = () => 1;
debounce(function(){ doThings(); })();
debounce(function(){ doThings(); }, 1000)();
debounce(function(a: string){ doThings(); }, 1000)("foo");
// Immediate true should return the value
const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for compose-function
// Project: https://github.com/component/debounce
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "debounce" {
// Overload on boolean constants would allow us to narrow further,
// but it is not implemented for TypeScript yet
function f<A extends Function>(f: A, interval?: number, immediate?: boolean): A
export default f;
}
+8
View File
@@ -0,0 +1,8 @@
///<reference path="email-addresses.d.ts"/>
import addrs = require('email-addresses');
var result: Object;
result = addrs.parseOneAddress('Jack Bowman <jack@fogcreek.com >');
result = addrs.parseAddressList(['foo@bar.com', 'Foo Bar <foo@bar.com>']);
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for email-addresses 2.0.1
// Project: https://github.com/jackbowman/email-addresses
// Definitions by: John Grimsey <https://github.com/johngrimsey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "email-addresses" {
function parseOneAddress(opts: any): Object;
function parseAddressList(opts: any): Object;
}
+531 -17
View File
@@ -1,16 +1,41 @@
///<reference path='eventemitter3.d.ts' />
///<reference path="eventemitter3.d.ts" />
///<reference path="../node/node.d.ts" />
///<reference path="../mocha/mocha.d.ts" />
'use strict';
import EventEmitter = require('eventemitter3');
import util = require('util');
import * as EventEmitter3ImportedAsES6Module from 'eventemitter3';
declare namespace Assume {
interface Class<T> {
new(...args: any[]): T;
}
interface Assume<T> {
equals(compare: T): Assume<T>;
equal(compare: T): Assume<T>;
eqls(compare: T): Assume<T>;
is: Assume<T>;
deep: Assume<T>;
to: Assume<T>;
either(arr: T[]): Assume<T>;
instanceOf(clazz: Class<T>): Assume<T>;
a(typeofString: string): Assume<T>;
}
export function assume<T>(input: T): Assume<T>;
}
let assume = Assume.assume;
class EventEmitterTest {
v: EventEmitter;
v: EventEmitter3.EventEmitter;
constructor() {
this.v = new EventEmitter();
this.v = new EventEmitter.EventEmitter();
this.v = new EventEmitter.EventEmitter2();
this.v = new EventEmitter.EventEmitter3();
this.v = new EventEmitter3ImportedAsES6Module();
var n: NodeJS.EventEmitter = this.v;
}
listeners() {
@@ -27,39 +52,528 @@ class EventEmitterTest {
on() {
var fn = () => console.log(1);
var v1: EventEmitter = this.v.on('click', fn);
var v2: EventEmitter = this.v.on('click', fn, this);
var v1: EventEmitter3.EventEmitter = this.v.on('click', fn);
var v2: EventEmitter3.EventEmitter = this.v.on('click', fn, this);
}
once() {
var fn = () => console.log(1);
var v1: EventEmitter = this.v.once('click', fn);
var v2: EventEmitter = this.v.once('click', fn, this);
var v1: EventEmitter3.EventEmitter = this.v.once('click', fn);
var v2: EventEmitter3.EventEmitter = this.v.once('click', fn, this);
}
removeListener() {
var fn = () => console.log(1);
var v1: EventEmitter = this.v.removeListener('click', fn);
var v2: EventEmitter = this.v.removeListener('click', fn, true);
var v1: EventEmitter3.EventEmitter = this.v.removeListener('click', fn);
var v2: EventEmitter3.EventEmitter = this.v.removeListener('click', fn, true);
}
removeAllListeners() {
var v1: EventEmitter = this.v.removeAllListeners('click');
var v1: EventEmitter3.EventEmitter = this.v.removeAllListeners('click');
}
off() {
var fn = () => console.log(1);
var v1: EventEmitter = this.v.off('click', fn);
var v2: EventEmitter = this.v.off('click', fn, true);
var v1: EventEmitter3.EventEmitter = this.v.off('click', fn);
var v2: EventEmitter3.EventEmitter = this.v.off('click', fn, true);
}
addListener() {
var fn = () => console.log(1);
var v1: EventEmitter = this.v.addListener('click', fn);
var v2: EventEmitter = this.v.addListener('click', fn, this);
var v1: EventEmitter3.EventEmitter = this.v.addListener('click', fn);
var v2: EventEmitter3.EventEmitter = this.v.addListener('click', fn, this);
}
setMaxListeners() {
var v1: EventEmitter = this.v.setMaxListeners();
var v1: EventEmitter3.EventEmitter = this.v.setMaxListeners();
}
}
describe('EventEmitter', function tests() {
'use strict';
it('exposes a `prefixed` property', function () {
assume(EventEmitter.prefixed).is.either([false, '~']);
});
it('inherits when used with require(util).inherits', function () {
class Beast extends EventEmitter {
/* rawr, i'm a beast */
}
util.inherits(Beast, EventEmitter);
var moop = new Beast()
, meap = new Beast();
assume(moop).is.instanceOf(Beast);
assume(moop).is.instanceOf(EventEmitter);
moop.listeners();
meap.listeners();
moop.on('data', function () {
throw new Error('I should not emit');
});
meap.emit('data', 'rawr');
meap.removeListener('foo');
meap.removeAllListeners();
});
describe('EventEmitter#emit', function () {
it('should return false when there are not events to emit', function () {
var e = new EventEmitter();
assume(e.emit('foo')).equals(false);
assume(e.emit('bar')).equals(false);
});
it('emits with context', function (done) {
var context = { bar: 'baz' }
, e = new EventEmitter();
e.on('foo', function (bar: string) {
assume(bar).equals('bar');
assume(this).equals(context);
done();
}, context).emit('foo', 'bar');
});
it('emits with context, multiple arguments (force apply)', function (done) {
var context = { bar: 'baz' }
, e = new EventEmitter();
e.on('foo', function (bar: string) {
assume(bar).equals('bar');
assume(this).equals(context);
done();
}, context).emit('foo', 'bar', 1,2,3,4,5,6,7,8,9,0);
});
it('can emit the function with multiple arguments', function () {
var e = new EventEmitter();
for(var i = 0; i < 100; i++) {
(function (j: number) {
for (var i = 0, args: number[] = []; i < j; i++) {
args.push(j);
}
e.once('args', function () {
assume(arguments.length).equals(args.length);
});
e.emit.apply(e, (['args'] as any[]).concat(args));
})(i);
}
});
it('can emit the function with multiple arguments, multiple listeners', function () {
var e = new EventEmitter();
for(var i = 0; i < 100; i++) {
(function (j: number) {
for (var i = 0, args: number[] = []; i < j; i++) {
args.push(j);
}
e.once('args', function () {
assume(arguments.length).equals(args.length);
});
e.once('args', function () {
assume(arguments.length).equals(args.length);
});
e.once('args', function () {
assume(arguments.length).equals(args.length);
});
e.once('args', function () {
assume(arguments.length).equals(args.length);
});
e.emit.apply(e, (['args'] as any[]).concat(args));
})(i);
}
});
it('emits with context, multiple listeners (force loop)', function () {
var e = new EventEmitter();
e.on('foo', function (bar: string) {
assume(this).eqls({ foo: 'bar' });
assume(bar).equals('bar');
}, { foo: 'bar' });
e.on('foo', function (bar: string) {
assume(this).eqls({ bar: 'baz' });
assume(bar).equals('bar');
}, { bar: 'baz' });
e.emit('foo', 'bar');
});
it('emits with different contexts', function () {
var e = new EventEmitter()
, pattern = '';
function writer() {
pattern += this;
}
e.on('write', writer, 'foo');
e.on('write', writer, 'baz');
e.once('write', writer, 'bar');
e.once('write', writer, 'banana');
e.emit('write');
assume(pattern).equals('foobazbarbanana');
});
it('should return true when there are events to emit', function (done) {
var e = new EventEmitter();
e.on('foo', function () {
process.nextTick(done);
});
assume(e.emit('foo')).equals(true);
assume(e.emit('foob')).equals(false);
});
it('receives the emitted events', function (done) {
var e = new EventEmitter();
e.on('data', function (a: string, b: EventEmitter3.EventEmitter, c: Date, d: void, undef: void) {
assume(a).equals('foo');
assume(b).equals(e);
assume(c).is.instanceOf(Date);
assume(undef).equals(undefined);
assume(arguments.length).equals(3);
done();
});
e.emit('data', 'foo', e, new Date());
});
it('emits to all event listeners', function () {
var e = new EventEmitter()
, pattern: string[] = [];
e.on('foo', function () {
pattern.push('foo1');
});
e.on('foo', function () {
pattern.push('foo2');
});
e.emit('foo');
assume(pattern.join(';')).equals('foo1;foo2');
});
(function each(keys: string[]) {
var key = keys.shift();
if (!key) return;
it('can store event which is a known property: '+ key, function (next) {
var e = new EventEmitter();
e.on(key, function (key: string) {
assume(key).equals(key);
next();
}).emit(key, key);
});
each(keys);
})([
'hasOwnProperty',
'constructor',
'__proto__',
'toString',
'toValue',
'unwatch',
'watch'
]);
});
describe('EventEmitter#listeners', function () {
it('returns an empty array if no listeners are specified', function () {
var e = new EventEmitter();
assume(e.listeners('foo')).is.a('array');
assume(e.listeners('foo').length).equals(0);
});
it('returns an array of function', function () {
var e = new EventEmitter();
function foo() {}
e.on('foo', foo);
assume(e.listeners('foo')).is.a('array');
assume(e.listeners('foo').length).equals(1);
assume(e.listeners('foo')).deep.equals([foo]);
});
it('is not vulnerable to modifications', function () {
var e = new EventEmitter();
function foo() {}
e.on('foo', foo);
assume(e.listeners('foo')).deep.equals([foo]);
e.listeners('foo').length = 0;
assume(e.listeners('foo')).deep.equals([foo]);
});
it('can return a boolean as indication if listeners exist', function () {
var e = new EventEmitter();
function foo() {}
e.once('once', foo);
e.once('multiple', foo);
e.once('multiple', foo);
e.on('on', foo);
e.on('multi', foo);
e.on('multi', foo);
assume(e.listeners('foo', true)).equals(false);
assume(e.listeners('multiple', true)).equals(true);
assume(e.listeners('on', true)).equals(true);
assume(e.listeners('multi', true)).equals(true);
e.removeAllListeners();
assume(e.listeners('multiple', true)).equals(false);
assume(e.listeners('on', true)).equals(false);
assume(e.listeners('multi', true)).equals(false);
});
});
describe('EventEmitter#once', function () {
it('only emits it once', function () {
var e = new EventEmitter()
, calls = 0;
e.once('foo', function () {
calls++;
});
e.emit('foo');
e.emit('foo');
e.emit('foo');
e.emit('foo');
e.emit('foo');
assume(e.listeners('foo').length).equals(0);
assume(calls).equals(1);
});
it('only emits once if emits are nested inside the listener', function () {
var e = new EventEmitter()
, calls = 0;
e.once('foo', function () {
calls++;
e.emit('foo');
});
e.emit('foo');
assume(e.listeners('foo').length).equals(0);
assume(calls).equals(1);
});
it('only emits once for multiple events', function () {
var e = new EventEmitter()
, multi = 0
, foo = 0
, bar = 0;
e.once('foo', function () {
foo++;
});
e.once('foo', function () {
bar++;
});
e.on('foo', function () {
multi++;
});
e.emit('foo');
e.emit('foo');
e.emit('foo');
e.emit('foo');
e.emit('foo');
assume(e.listeners('foo').length).equals(1);
assume(multi).equals(5);
assume(foo).equals(1);
assume(bar).equals(1);
});
it('only emits once with context', function (done) {
var context = { foo: 'bar' }
, e = new EventEmitter();
e.once('foo', function (bar: string) {
assume(this).equals(context);
assume(bar).equals('bar');
done();
}, context).emit('foo', 'bar');
});
});
describe('EventEmitter#removeListener', function () {
it('should only remove the event with the specified function', function () {
var e = new EventEmitter();
function bar() {}
e.on('foo', function () {});
e.on('bar', function () {});
e.on('bar', bar);
assume(e.removeListener('foo', bar)).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.listeners('bar').length).equals(2);
assume(e.removeListener('foo')).equals(e);
assume(e.listeners('foo').length).equals(0);
assume(e.listeners('bar').length).equals(2);
assume(e.removeListener('bar', bar)).equals(e);
assume(e.listeners('bar').length).equals(1);
assume(e.removeListener('bar')).equals(e);
assume(e.listeners('bar').length).equals(0);
});
it('should only remove once events when using the once flag', function () {
var e = new EventEmitter();
function foo() {}
e.on('foo', foo);
assume(e.removeListener('foo', function () {}, undefined, true)).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.removeListener('foo', foo, undefined, true)).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.removeListener('foo', foo)).equals(e);
assume(e.listeners('foo').length).equals(0);
e.on('foo', foo);
e.once('foo', foo);
assume(e.removeListener('foo', function () {}, undefined, true)).equals(e);
assume(e.listeners('foo').length).equals(2);
assume(e.removeListener('foo', foo, undefined, true)).equals(e);
assume(e.listeners('foo').length).equals(1);
e.once('foo', foo);
assume(e.removeListener('foo', foo)).equals(e);
assume(e.listeners('foo').length).equals(0);
});
it('should only remove listeners matching the correct context', function () {
var e = new EventEmitter()
, context = { foo: 'bar' };
function foo() {}
function bar() {}
e.on('foo', foo, context);
assume(e.listeners('foo').length).equals(1);
assume(e.removeListener('foo', function () {}, context)).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.removeListener('foo', foo, { baz: 'quux' })).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.removeListener('foo', foo, context)).equals(e);
assume(e.listeners('foo').length).equals(0);
e.on('foo', foo, context);
e.on('foo', bar);
assume(e.listeners('foo').length).equals(2);
assume(e.removeListener('foo', foo, { baz: 'quux' })).equals(e);
assume(e.listeners('foo').length).equals(2);
assume(e.removeListener('foo', foo, context)).equals(e);
assume(e.listeners('foo').length).equals(1);
assume(e.listeners('foo')[0]).equals(bar);
e.on('foo', foo, context);
assume(e.listeners('foo').length).equals(2);
assume(e.removeAllListeners('foo')).equals(e);
assume(e.listeners('foo').length).equals(0);
});
});
describe('EventEmitter#removeAllListeners', function () {
it('removes all events for the specified events', function () {
var e = new EventEmitter();
e.on('foo', function () { throw new Error('oops'); });
e.on('foo', function () { throw new Error('oops'); });
e.on('bar', function () { throw new Error('oops'); });
e.on('aaa', function () { throw new Error('oops'); });
assume(e.removeAllListeners('foo')).equals(e);
assume(e.listeners('foo').length).equals(0);
assume(e.listeners('bar').length).equals(1);
assume(e.listeners('aaa').length).equals(1);
assume(e.removeAllListeners('bar')).equals(e);
assume(e.removeAllListeners('aaa')).equals(e);
assume(e.emit('foo')).equals(false);
assume(e.emit('bar')).equals(false);
assume(e.emit('aaa')).equals(false);
});
it('just nukes the fuck out of everything', function () {
var e = new EventEmitter();
e.on('foo', function () { throw new Error('oops'); });
e.on('foo', function () { throw new Error('oops'); });
e.on('bar', function () { throw new Error('oops'); });
e.on('aaa', function () { throw new Error('oops'); });
assume(e.removeAllListeners()).equals(e);
assume(e.listeners('foo').length).equals(0);
assume(e.listeners('bar').length).equals(0);
assume(e.listeners('aaa').length).equals(0);
assume(e.emit('foo')).equals(false);
assume(e.emit('bar')).equals(false);
assume(e.emit('aaa')).equals(false);
});
});
describe('#setMaxListeners', function () {
it('is a function', function () {
var e = new EventEmitter();
assume(e.setMaxListeners).is.a('function');
});
it('returns self when called', function () {
var e = new EventEmitter();
assume(e.setMaxListeners()).to.equal(e);
});
});
});
+51 -30
View File
@@ -1,11 +1,14 @@
// Type definitions for EventEmitter3 0.1.6
// Type definitions for EventEmitter3 1.1.1
// Project: https://github.com/primus/eventemitter3
// Definitions by: Yuichi Murata <https://github.com/mrk21>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Definitions by: Yuichi Murata <https://github.com/mrk21>, Leon Yu <https://github.com/leonyu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module EventEmitter3 {
// __Base is hack for https://github.com/Microsoft/TypeScript/issues/3602
class __Base {
declare namespace EventEmitter3 {
interface EventEmitter3Static {
new (): EventEmitter;
prefixed: string | boolean;
}
class EventEmitter {
/**
* Minimal EventEmitter interface that is molded against the Node.js
* EventEmitter interface.
@@ -22,7 +25,17 @@ declare module EventEmitter3 {
* @returns {Array}
* @api public
*/
listeners(event: string): Function[];
listeners(event?: string): Function[];
/**
* Return a list of assigned event listeners.
*
* @param {String} event The events that should be listed.
* @param {Boolean} exists We only need to know if there are listeners.
* @returns {Boolean}
* @api public
*/
listeners(event: string, param: boolean): boolean;
/**
* Emit an event to all registered event listeners.
@@ -37,8 +50,8 @@ declare module EventEmitter3 {
* Register a new EventListener for the given event.
*
* @param {String} event Name of the event.
* @param {Functon} fn Callback function.
* @param {Mixed} context The context of the function.
* @param {Function} fn Callback function.
* @param {Mixed} [context=this] The context of the function.
* @api public
*/
on(event: string, fn: Function, context?: any): EventEmitter;
@@ -48,7 +61,7 @@ declare module EventEmitter3 {
*
* @param {String} event Name of the event.
* @param {Function} fn Callback function.
* @param {Mixed} context The context of the function.
* @param {Mixed} [context=this] The context of the function.
* @api public
*/
once(event: string, fn: Function, context?: any): EventEmitter;
@@ -58,10 +71,11 @@ declare module EventEmitter3 {
*
* @param {String} event The event we want to remove.
* @param {Function} fn The listener that we need to find.
* @param {Mixed} context Only remove listeners matching this context.
* @param {Boolean} once Only remove once listeners.
* @api public
*/
removeListener(event: string, fn: Function, once?: boolean): EventEmitter;
removeListener(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter;
/**
* Remove all listeners or only the listeners for the specified event.
@@ -69,34 +83,41 @@ declare module EventEmitter3 {
* @param {String} event The event want to remove all listeners for.
* @api public
*/
removeAllListeners(event: string): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
//
// Alias methods names because people roll like that.
//
off(event: string, fn: Function, once?: boolean): EventEmitter;
/**
* Remove event listeners.
*
* @param {String} event The event we want to remove.
* @param {Function} fn The listener that we need to find.
* @param {Mixed} context Only remove listeners matching this context.
* @param {Boolean} once Only remove once listeners.
* @api public
*/
off(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter;
/**
* Register a new EventListener for the given event.
*
* @param {String} event Name of the event.
* @param {Function} fn Callback function.
* @param {Mixed} [context=this] The context of the function.
* @api public
*/
addListener(event: string, fn: Function, context?: any): EventEmitter;
//
// This function doesn't apply anymore.
//
/**
* This function doesn't apply anymore.
* @deprecated
*/
setMaxListeners(): EventEmitter;
}
export class EventEmitter extends __Base { }
export module EventEmitter {
//
// Expose the module.
//
export class EventEmitter extends __Base {}
export class EventEmitter2 extends __Base {}
export class EventEmitter3 extends __Base {}
}
}
declare module 'eventemitter3' {
//
// Expose the module.
//
class EventEmitter extends EventEmitter3.EventEmitter {}
export = EventEmitter;
var EventEmitter3: EventEmitter3.EventEmitter3Static;
export = EventEmitter3;
}
+1 -1
View File
@@ -345,7 +345,7 @@ declare module fabric {
* @param eventName Event name (eg. 'after:render') or object with key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})
* @param handler Function to be deleted from EventListeners
*/
off(eventName: string|any, handler: (e: IEvent) => any): T;
off(eventName?: string|any, handler?: (e: IEvent) => any): T;
}
// animation mixin
+1
View File
@@ -247,6 +247,7 @@ declare module FullCalendar {
backgroundColor?: string;
borderColor?: string;
textColor?: string;
rendering?: string;
}
export interface ViewObject extends Timespan {
+9 -9
View File
@@ -450,14 +450,14 @@ declare module GitHubElectron {
interface WebPreferences {
nodeIntegration?: boolean;
preload?: string;
partition: string;
zoomFactor: number;
javascript: boolean;
webSecurity: boolean;
allowDisplayingInsecureContent: boolean;
allowRunningInsecureContent: boolean;
images: boolean;
textAreasAreResizable: boolean;
partition?: string;
zoomFactor?: number;
javascript?: boolean;
webSecurity?: boolean;
allowDisplayingInsecureContent?: boolean;
allowRunningInsecureContent?: boolean;
images?: boolean;
textAreasAreResizable?: boolean;
webgl?: boolean;
webaudio?: boolean;
plugins?: boolean;
@@ -1700,7 +1700,7 @@ declare module GitHubElectron {
interface Electron {
clipboard: GitHubElectron.Clipboard;
crashReporter: GitHubElectron.CrashReporter;
nativeImage: GitHubElectron.NativeImage;
nativeImage: typeof GitHubElectron.NativeImage;
screen: GitHubElectron.Screen;
shell: GitHubElectron.Shell;
remote: GitHubElectron.Remote;
+1
View File
@@ -365,6 +365,7 @@ declare module google {
export interface TransitionAnimation {
duration?: number;
easing?: string; // linear, in, out, inAndOut
startup?: boolean;
}
export interface ChartAxis {
+1 -1
View File
@@ -124,7 +124,7 @@ var fs = require('fs');
openInbox(function(err : Error, box : IMAP.Box) {
if (err) throw err;
imap.search([ 'UNSEEN', ['SINCE', 'May 20, 2010'] ], function(err : Error, results : string[]) {
imap.search([ 'UNSEEN', ['SINCE', 'May 20, 2010'] ], function(err : Error, results : number[]) {
if (err) throw err;
var f = imap.fetch(results, { bodies: '' });
f.on('message', function(msg : IMAP.ImapMessage, seqno : number) {
+71 -34
View File
@@ -83,34 +83,68 @@ declare module IMAP {
};
}
export interface ImapMessageBodyInfo {
/** The specifier for this body (e.g. 'TEXT', 'HEADER.FIELDS (TO FROM SUBJECT)', etc). */
which: string;
/** The size of this body in bytes. */
size: number;
}
export interface ImapMessageAttributes {
/** A 32-bit ID that uniquely identifies this message within its mailbox. */
uid: number;
/** A list of flags currently set on this message. */
flags: string[];
/** The internal server date for the message. */
date: Date;
/** The message's body structure (only set if requested with fetch()). */
struct?: any[];
/** The RFC822 message size (only set if requested with fetch()). */
size?: number;
}
/** Given in a 'message' event from ImapFetch */
export interface ImapMessage extends NodeJS.EventEmitter { }
export interface ImapMessage extends NodeJS.EventEmitter {
on(event: string, listener: Function): this;
on(event: 'body', listener: (stream: NodeJS.ReadableStream, info: ImapMessageBodyInfo) => void): this;
on(event: 'attributes', listener: (attrs: ImapMessageAttributes) => void): this;
on(event: 'end', listener: () => void): this;
}
export interface FetchOptions {
/** Mark message(s) as read when fetched. Default: false */
markSeen?: boolean;
markSeen?: boolean;
/** Fetch the message structure. Default: false */
struct?: boolean;
struct?: boolean;
/** Fetch the message envelope. Default: false */
envelope?: boolean;
envelope?: boolean;
/** Fetch the RFC822 size. Default: false */
size?: boolean;
size?: boolean;
/** Fetch modifiers defined by IMAP extensions. Default: (none) */
modifiers?: Object;
modifiers?: Object;
/** A string or Array of strings containing the body part section to fetch. Default: (none) Example sections: */
bodies?: any; /* string|string[] */
bodies?: string | string[];
}
/** Returned from fetch() */
export interface ImapFetch extends NodeJS.EventEmitter { }
export interface ImapFetch extends NodeJS.EventEmitter {
on(event: string, listener: Function): this;
on(event: 'message', listener: (message: ImapMessage, seqno: number) => void): this;
on(event: 'error', listener: (error: Error) => void): this;
once(event: string, listener: Function): this;
once(event: 'error', listener: (error: Error) => void): this;
}
export interface Folder {
/** mailbox attributes. An attribute of 'NOSELECT' indicates the mailbox cannot be opened */
attribs: string[];
/** hierarchy delimiter for accessing this mailbox's direct children. */
delimiter: string;
children: Folder[];
/** an object containing another structure similar in format to this top level, otherwise null if no children */
children: MailBoxes;
/** pointer to parent mailbox, null if at the top level */
parent: Folder;
}
@@ -129,10 +163,11 @@ declare module IMAP {
date?: Date;
}
export interface MessageFunctions {
/** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate.
The following message flags are valid types that do not have arguments:
// search() criteria
/**
// The following message flags are valid types that do not have arguments:
ALL: void; // All messages.
ANSWERED: void; // Messages with the Answered flag set.
DELETED: void; // Messages with the Deleted flag set.
@@ -148,7 +183,7 @@ declare module IMAP {
UNFLAGGED: void; // Messages that do not have the Flagged flag set.
UNSEEN: void; // Messages that do not have the Seen flag set.
// The following are valid types that require string value(s):
The following are valid types that require string value(s):
BCC: any; // Messages that contain the specified string in the BCC field.
CC: any; // Messages that contain the specified string in the CC field.
@@ -159,25 +194,27 @@ declare module IMAP {
TEXT: any; // Messages that contain the specified string in the header OR the message body.
KEYWORD: any; // Messages with the specified keyword set.
HEADER: any; // Requires two string values, with the first being the header name and the second being the value to search for. If this second string is empty, all messages that contain the given header name will be returned.
// The following are valid types that require a string parseable by JavaScripts Date object OR a Date instance:
The following are valid types that require a string parseable by JavaScripts Date object OR a Date instance:
BEFORE: any; // Messages whose internal date (disregarding time and timezone) is earlier than the specified date.
ON: any; // Messages whose internal date (disregarding time and timezone) is within the specified date.
SINCE: any; // Messages whose internal date (disregarding time and timezone) is within or later than the specified date.
SENTBEFORE: any; // Messages whose Date header (disregarding time and timezone) is earlier than the specified date.
SENTON: any; // Messages whose Date header (disregarding time and timezone) is within the specified date.
SENTSINCE: any; // Messages whose Date header (disregarding time and timezone) is within or later than the specified date.
//The following are valid types that require one Integer value:
The following are valid types that require one Integer value:
LARGER: number; // Messages with a size larger than the specified number of bytes.
SMALLER: number; // Messages with a size smaller than the specified number of bytes.
// The following are valid criterion that require one or more Integer values:
The following are valid criterion that require one or more Integer values:
UID: any; // Messages with UIDs corresponding to the specified UID set. Ranges are permitted (e.g. '2504:2507' or '*' or '2504:*').
*/
export interface MessageFunctions {
/** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. */
search(criteria: any[], callback: (error: Error, uids: string[]) => void): void;
/** Fetches message(s) in the currently open mailbox. */
*/
search(criteria: any[], callback: (error: Error, uids: number[]) => void): void;
/** Fetches message(s) in the currently open mailbox; source can be a single message identifier, a message identifier range (e.g. '2504:2507' or '*' or '2504:*'), an array of message identifiers, or an array of message identifier ranges. */
fetch(source: any /* MessageSource */, options: FetchOptions): ImapFetch;
/** Copies message(s) in the currently open mailbox to another mailbox. */
copy(source: any /* MessageSource */, mailboxName: string, callback: (error: Error) => void): void;
@@ -199,26 +236,23 @@ declare module IMAP {
serverSupports(capability: string): boolean;
}
export class Connection implements NodeJS.EventEmitter, MessageFunctions {
/** @constructor */
constructor(config: Config);
// from NodeJS.EventEmitter
addListener(event: string, listener: Function): NodeJS.EventEmitter;
on(event: string, listener: Function): NodeJS.EventEmitter;
once(event: string, listener: Function): NodeJS.EventEmitter;
removeListener(event: string, listener: Function): NodeJS.EventEmitter;
removeAllListeners(event?: string): NodeJS.EventEmitter;
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): void;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
// from MessageFunctions
/** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. */
search(criteria: any[], callback: (error: Error, uids: string[]) => void): void;
search(criteria: any[], callback: (error: Error, uids: number[]) => void): void;
/** Fetches message(s) in the currently open mailbox. */
fetch(source: any /* MessageSource */, options: FetchOptions): ImapFetch;
/** Copies message(s) in the currently open mailbox to another mailbox. */
@@ -241,7 +275,7 @@ declare module IMAP {
serverSupports(capability: string): boolean;
/** Parses a raw header and returns an object keyed on header fields and the values are Arrays of header field values. Set disableAutoDecode to true to disable automatic decoding of MIME encoded-words that may exist in header field values. */
static parseHeader(rawHeader: string, disableAutoDecode?: boolean): any;
static parseHeader(rawHeader: string, disableAutoDecode?: boolean): {[index: string]: string[]};
/** The current state of the connection (e.g. 'disconnected', 'connected', 'authenticated'). */
state: string;
@@ -256,6 +290,9 @@ declare module IMAP {
/** Mailboxes that are accessible by any logged in user. */
shared: any[];
};
/**
seq exposes the search() ... serverSupports() set of commands, but returns sequence number(s) instead of UIDs.
*/
seq: MessageFunctions;
/** Attempts to connect and authenticate with the IMAP server. */
connect(): void;
@@ -273,7 +310,7 @@ declare module IMAP {
/** Creates a new mailbox on the server. mailboxName should include any necessary prefix/path. */
addBox(mailboxName: string, callback: (error: Error) => void): void;
/** Removes a specific mailbox that exists on the server. mailboxName should including any necessary prefix/path. */
delBox(mailboxName: string, callback: (error: Error, uids: string[]) => void): void;
delBox(mailboxName: string, callback: (error: Error) => void): void;
/** Renames a specific mailbox that exists on the server. Both oldMailboxName and newMailboxName should include any necessary prefix/path. Note: Renaming the 'INBOX' mailbox will instead cause all messages in 'INBOX' to be moved to the new mailbox. */
renameBox(oldMailboxName: string, newMailboxName: string, callback: (error: Error, mailbox: Box) => void): void;
/** Subscribes to a specific mailbox that exists on the server. mailboxName should include any necessary prefix/path. */
+7
View File
@@ -46,4 +46,11 @@ let hmac5:string = shaObj1.getHMAC("HEX", { outputUpper: true, b64Pad: '=' });
shaObj.setHMACKey("abc", "TEXT");
shaObj.update("This is a test");
let hmac = shaObj.getHMAC("HEX");
}
// Browser global test
{
var shaObj = new jsSHA("SHA-512", "TEXT");
shaObj.update("This is a test");
var hash = shaObj.getHash("HEX");
}
+2 -2
View File
@@ -79,7 +79,7 @@ declare module jsSHA {
}
}
declare var jsSHA: jsSHA.jsSHA;
declare module 'jssha' {
var jsSHA: jsSHA.jsSHA;
export = jsSHA;
}
}
+70 -70
View File
@@ -39,7 +39,7 @@ declare module "knex" {
//
// QueryInterface
//
interface QueryInterface {
select: Select;
as: As;
@@ -49,7 +49,7 @@ declare module "knex" {
into: Table;
table: Table;
distinct: Distinct;
// Joins
join: Join;
joinRaw: JoinRaw;
@@ -61,7 +61,7 @@ declare module "knex" {
outerJoin: Join;
fullOuterJoin: Join;
crossJoin: Join;
// Wheres
where: Where;
andWhere: Where;
@@ -86,29 +86,29 @@ declare module "knex" {
whereNotBetween: WhereBetween;
orWhereBetween: WhereBetween;
orWhereNotBetween: WhereBetween;
// Group by
groupBy: GroupBy;
groupByRaw: RawQueryBuilder;
// Order by
orderBy: OrderBy;
orderByRaw: RawQueryBuilder;
// Union
union: Union;
unionAll(callback: Function): QueryBuilder;
// Having
having: Having;
havingRaw: RawQueryBuilder;
orHaving: Having;
orHavingRaw: RawQueryBuilder;
// Paging
offset(offset: number): QueryBuilder;
limit(limit: number): QueryBuilder;
// Aggregation
count(columnName?: string): QueryBuilder;
min(columnName: string): QueryBuilder;
@@ -117,43 +117,43 @@ declare module "knex" {
avg(columnName: string): QueryBuilder;
increment(columnName: string, amount?: number): QueryBuilder;
decrement(columnName: string, amount?: number): QueryBuilder;
// Others
first(...columns: string[]): QueryBuilder;
debug(enabled?: boolean): QueryBuilder;
pluck(column: string): QueryBuilder;
insert(data: any, returning?: string | string[]): QueryBuilder;
update(data: any, returning?: string | string[]): QueryBuilder;
update(columnName: string, value: Value, returning?: string | string[]): QueryBuilder;
returning(column: string): QueryBuilder;
del(returning?: string | string[]): QueryBuilder;
delete(returning?: string | string[]): QueryBuilder;
truncate(): QueryBuilder;
transacting(trx: Transaction): QueryBuilder;
connection(connection: any): QueryBuilder;
clone(): QueryBuilder;
}
interface As {
(columnName: string): QueryBuilder;
}
interface Select extends ColumnNameQueryBuilder {
}
interface Table {
(tableName: string): QueryBuilder;
(callback: Function): QueryBuilder;
}
interface Distinct extends ColumnNameQueryBuilder {
}
interface Join {
(raw: Raw): QueryBuilder;
(tableName: string, callback: Function): QueryBuilder;
@@ -161,126 +161,126 @@ declare module "knex" {
(tableName: string, column1: string, raw: Raw): QueryBuilder;
(tableName: string, column1: string, operator: string, column2: string): QueryBuilder;
}
interface JoinRaw {
(tableName: string, binding?: Value): QueryBuilder;
}
interface Where extends WhereRaw, WhereWrapped, WhereNull {
(object: Object): QueryBuilder;
(columnName: string, value: Value): QueryBuilder;
(columnName: string, operator: string, value: Value): QueryBuilder;
(columnName: string, operator: string, query: QueryBuilder): QueryBuilder;
}
interface WhereRaw extends RawQueryBuilder {
(condition: boolean): QueryBuilder;
}
interface WhereWrapped {
(callback: Function): QueryBuilder;
}
interface WhereNull {
(columnName: string): QueryBuilder;
}
interface WhereIn {
(columnName: string, values: Value[]): QueryBuilder;
(columnName: string, callback: Function): QueryBuilder;
(columnName: string, query: QueryBuilder): QueryBuilder;
}
interface WhereBetween {
(columnName: string, range: [Value, Value]): QueryBuilder;
}
interface WhereExists {
(callback: Function): QueryBuilder;
(query: QueryBuilder): QueryBuilder;
}
interface WhereNull {
(columnName: string): QueryBuilder;
}
interface WhereIn {
(columnName: string, values: Value[]): QueryBuilder;
}
interface GroupBy extends RawQueryBuilder, ColumnNameQueryBuilder {
}
interface OrderBy {
(columnName: string, direction?: string): QueryBuilder;
}
interface Union {
(callback: Function, wrap?: boolean): QueryBuilder;
(callbacks: Function[], wrap?: boolean): QueryBuilder;
(...callbacks: Function[]): QueryBuilder;
// (...callbacks: Function[], wrap?: boolean): QueryInterface;
}
interface Having extends RawQueryBuilder, WhereWrapped {
(tableName: string, column1: string, operator: string, column2: string): QueryBuilder;
}
// commons
interface ColumnNameQueryBuilder {
(...columnNames: ColumnName[]): QueryBuilder;
(columnNames: ColumnName[]): QueryBuilder;
}
interface RawQueryBuilder {
(sql: string, ...bindings: Value[]): QueryBuilder;
(sql: string, bindings: Value[]): QueryBuilder;
(raw: Raw): QueryBuilder;
}
// Raw
interface Raw extends events.EventEmitter, ChainableInterface {
wrap(before: string, after: string): Raw;
}
interface RawBuilder {
(value: Value): Raw;
(sql: string, ...bindings: Value[]): Raw;
(sql: string, bindings: Value[]): Raw;
}
//
// QueryBuilder
//
interface QueryBuilder extends QueryInterface, ChainableInterface {
or: QueryBuilder;
and: QueryBuilder;
//TODO: Promise?
columnInfo(column?: string): Promise<ColumnInfo>;
forUpdate(): QueryBuilder;
forShare(): QueryBuilder;
toSQL(): Sql;
on(event: string, callback: Function): QueryBuilder;
}
interface Sql {
method: string;
options: any;
bindings: Value[];
sql: string;
}
//
// Chainable interface
//
interface ChainableInterface extends Promise<any> {
toQuery(): string;
options(options: any): QueryBuilder;
@@ -289,16 +289,16 @@ declare module "knex" {
pipe(writable: any): QueryBuilder;
exec(callback: Function): QueryBuilder;
}
interface Transaction extends QueryBuilder {
commit: any;
rollback: any;
}
//
// Schema builder
//
interface SchemaBuilder {
createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): Promise<void>;
renameTable(oldTableName: string, newTableName: string): Promise<void>;
@@ -309,7 +309,7 @@ declare module "knex" {
dropTableIfExists(tableName: string): Promise<void>;
raw(statement: string): SchemaBuilder;
}
interface TableBuilder {
increments(columnName?: string): ColumnBuilder;
dropColumn(columnName: string): TableBuilder;
@@ -336,24 +336,24 @@ declare module "knex" {
specificType(columnName: string, type: string): ColumnBuilder;
primary(columnNames: string[]) : TableBuilder;
index(columnNames: string[], indexName?: string, indexType?: string) : TableBuilder;
unique(columnNames: string[], indexName?: string) : TableBuilder;
unique(columnNames: string[], indexName?: string) : TableBuilder;
}
interface CreateTableBuilder extends TableBuilder {
}
interface MySqlTableBuilder extends CreateTableBuilder {
engine(val: string): CreateTableBuilder;
charset(val: string): CreateTableBuilder;
collate(val: string): CreateTableBuilder;
}
interface AlterTableBuilder extends TableBuilder {
}
interface MySqlAlterTableBuilder extends AlterTableBuilder {
}
interface ColumnBuilder {
index(indexName?: string): ColumnBuilder;
primary(): ColumnBuilder;
@@ -367,34 +367,34 @@ declare module "knex" {
nullable(): ColumnBuilder;
comment(value: string): ColumnBuilder;
}
interface PostgreSqlColumnBuilder extends ColumnBuilder {
index(indexName?: string, indexType?: string): ColumnBuilder;
}
interface ReferencingColumnBuilder {
inTable(tableName: string): ColumnBuilder;
}
interface AlterColumnBuilder extends ColumnBuilder {
}
interface MySqlAlterColumnBuilder extends AlterColumnBuilder {
first(): AlterColumnBuilder;
after(columnName: string): AlterColumnBuilder;
}
//
// Configurations
//
interface ColumnInfo {
defaultValue: Value;
type: string;
maxLength: number;
nullable: boolean;
}
interface Config {
debug?: boolean;
client?: string;
@@ -404,7 +404,7 @@ declare module "knex" {
pool?: PoolConfig;
migrations?: MigrationConfig;
}
interface ConnectionConfig {
host: string;
user: string;
@@ -412,13 +412,13 @@ declare module "knex" {
database: string;
debug?: boolean;
}
/** Used with SQLite3 adapter */
interface Sqlite3ConnectionConfig {
filename: string;
debug?: boolean;
}
interface SocketConnectionConfig {
socketPath: string;
user: string;
@@ -426,7 +426,7 @@ declare module "knex" {
database: string;
debug?: boolean;
}
interface PoolConfig {
name?: string;
create?: Function;
@@ -443,7 +443,7 @@ declare module "knex" {
validate?: Function;
log?: boolean;
}
interface MigrationConfig {
database?: string;
directory?: string;
+2 -1
View File
@@ -131,6 +131,7 @@ var layer = L.tileLayer("http://{s}.example.net/{x}/{y}/{z}.png");
map.addLayer(layer);
map.addLayer(layer, false);
map.eachLayer(l => {});
map.removeLayer(layer);
map.hasLayer(layer);
@@ -423,4 +424,4 @@ var zoomCtrl = L.control.zoom({
position: "topleft",
zoomInText: '+',
zoomOutText: '-'
});
});
+8 -2
View File
@@ -516,7 +516,7 @@ declare module L {
function (options?: ControlOptions): Control;
}
namespace control {
export namespace control {
/**
* Creates a zoom control.
@@ -2441,6 +2441,12 @@ declare namespace L {
*/
options: Map.MapOptions;
/**
* Iterates over the layers of the map, optionally specifying context
* of the iterator function.
*/
eachLayer(fn: (layer: ILayer) => void, context?: any): Map;
////////////////
////////////////
addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Map;
@@ -3261,7 +3267,7 @@ declare namespace L {
off(eventMap?: any, context?: any): Path;
}
namespace Path {
export namespace Path {
/**
* True if SVG is used for vector rendering (true for most modern browsers).
*/
+84 -34
View File
@@ -5444,17 +5444,34 @@ module TestIsBoolean {
}
// _.isDate
result = <boolean>_.isDate(any);
result = <boolean>_(42).isDate();
result = <boolean>_<any>([]).isDate();
result = <boolean>_({}).isDate();
{
let value: Date|string = "foo";
if (_.isDate(value)) {
value.toTimeString();
} else {
value.charAt(0);
}
module TestIsBoolean {
{
let value: number|Date;
if (_.isDate(value)) {
let result: Date = value;
}
else {
let result: number = value;
}
}
{
let result: boolean;
result = _.isDate(any);
result = _(42).isDate();
result = _<any>([]).isDate();
result = _({}).isDate();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(42).chain().isDate();
result = _<any>([]).chain().isDate();
result = _({}).chain().isDate();
}
}
// _.isElement
@@ -5532,17 +5549,34 @@ result = <boolean>_<any>([]).isFinite();
result = <boolean>_({}).isFinite();
// _.isFunction
result = <boolean>_.isFunction(any);
result = <boolean>_(1).isFunction();
result = <boolean>_<any>([]).isFunction();
result = <boolean>_({}).isFunction();
{
let value: Function|string = "foo";
if (_.isFunction(value)) {
value();
} else {
let result: string = value;
}
module TestIsFunction {
{
let value: number|Function;
if (_.isFunction(value)) {
let result: Function = value;
}
else {
let result: number = value;
}
}
{
let result: boolean;
result = _.isFunction(any);
result = _(1).isFunction();
result = _<any>([]).isFunction();
result = _({}).isFunction();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isFunction();
result = _<any>([]).chain().isFunction();
result = _({}).chain().isFunction();
}
}
// _.isMatch
@@ -5635,18 +5669,34 @@ result = <boolean>_<any>([]).isPlainObject();
result = <boolean>_({}).isPlainObject();
// _.isRegExp
result = <boolean>_.isRegExp(any);
result = <boolean>_(1).isRegExp();
result = <boolean>_<any>([]).isRegExp();
result = <boolean>_({}).isRegExp();
{
let value: RegExp|string = /^foo$/g;
if (_.isRegExp(value)) {
let regex: RegExp = value;
let index: number = value.exec("foo").index;
} else {
let result: string = value;
}
module TestIsRegExp {
{
let value: number|RegExp;
if (_.isRegExp(value)) {
let result: RegExp = value;
}
else {
let result: number = value;
}
}
{
let result: boolean;
result = _.isRegExp(any);
result = _(1).isRegExp();
result = _<any>([]).isRegExp();
result = _({}).isRegExp();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isRegExp();
result = _<any>([]).chain().isRegExp();
result = _({}).chain().isRegExp();
}
}
// _.isString
+26 -2
View File
@@ -9285,8 +9285,9 @@ declare module _ {
/**
* Checks if value is classified as a Date object.
* @param value The value to check.
*
* @return Returns true if value is correctly classified, else false.
**/
*/
isDate(value?: any): value is Date;
}
@@ -9297,6 +9298,13 @@ declare module _ {
isDate(): boolean;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* @see _.isDate
*/
isDate(): LoDashExplicitWrapper<boolean>;
}
//_.isElement
interface LoDashStatic {
/**
@@ -9434,9 +9442,10 @@ declare module _ {
interface LoDashStatic {
/**
* Checks if value is classified as a Function object.
*
* @param value The value to check.
* @return Returns true if value is correctly classified, else false.
**/
*/
isFunction(value?: any): value is Function;
}
@@ -9447,6 +9456,13 @@ declare module _ {
isFunction(): boolean;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* @see _.isFunction
*/
isFunction(): LoDashExplicitWrapper<boolean>;
}
//_.isMatch
interface isMatchCustomizer {
(value: any, other: any, indexOrKey?: number|string): boolean;
@@ -9605,6 +9621,7 @@ declare module _ {
/**
* Checks if value is classified as a RegExp object.
* @param value The value to check.
*
* @return Returns true if value is correctly classified, else false.
*/
isRegExp(value?: any): value is RegExp;
@@ -9617,6 +9634,13 @@ declare module _ {
isRegExp(): boolean;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* see _.isRegExp
*/
isRegExp(): LoDashExplicitWrapper<boolean>;
}
//_.isString
interface LoDashStatic {
/**
+10
View File
@@ -40,6 +40,8 @@ function test() {
function testExporter() {
new makerjs.exporter.Exporter({});
makerjs.exporter.toDXF(model);
makerjs.exporter.toOpenJsCad(model);
makerjs.exporter.toSTL(model);
makerjs.exporter.toSVG(model);
makerjs.exporter.tryGetModelUnits(model);
}
@@ -66,12 +68,17 @@ function test() {
function testModel(){
makerjs.model.combine(model, model, true, false, true, false);
makerjs.model.convertUnits(model, makerjs.unitType.Centimeter);
makerjs.model.countChildModels(model);
makerjs.model.detachLoop(model);
makerjs.model.findLoops(model);
makerjs.model.getSimilarPathId(model, 'foo');
makerjs.model.isPathInsideModel(paths.line, model);
makerjs.model.mirror(model, false, true);
makerjs.model.move(makerjs.model.originate(model, [9,9]), [0,0]);
makerjs.model.moveRelative(model, [1,1]);
makerjs.model.originate(model);
makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]);
makerjs.model.scale(model, 7);
makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {});
}
@@ -80,6 +87,7 @@ function test() {
new makerjs.models.BoltCircle(7, 7, 7, 7),
new makerjs.models.BoltRectangle(2, 2, 2),
new makerjs.models.ConnectTheDots(true, [ [0,0], [1,1] ]),
new makerjs.models.Dome(5, 7),
new makerjs.models.Oval(7, 7),
new makerjs.models.OvalArc(6, 4, 2, 12),
new makerjs.models.Polygon(7, 5),
@@ -141,7 +149,9 @@ function test() {
makerjs.point.middle(paths.line);
makerjs.point.mirror(p1, true, false);
makerjs.point.rotate(p1, 5, p2);
makerjs.point.rounded(p1);
makerjs.point.scale(p2, 8);
makerjs.point.serialize(p1);
makerjs.point.subtract(p2, p1);
makerjs.point.zero();
}
+125 -10
View File
@@ -247,6 +247,37 @@ declare module MakerJs {
*/
path2Angles?: number[];
}
/**
* Options when matching points
*/
interface IPointMatchOptions {
/**
* Optional exemplar of number of decimal places.
*/
accuracy?: number;
}
/**
* Options to pass to model.findLoops.
*/
interface IFindLoopsOptions extends IPointMatchOptions {
/**
* Flag to remove looped paths from the original model.
*/
removeFromOriginal?: boolean;
}
/**
* A path that may be indicated to "flow" in either direction between its endpoints.
*/
interface IPathDirectional extends IPath {
/**
* The endpoints of the path.
*/
endPoints: IPoint[];
/**
* Path flows forwards or reverse.
*/
reversed?: boolean;
}
/**
* Path objects by id.
*/
@@ -302,6 +333,12 @@ declare module MakerJs {
*/
layer?: string;
}
/**
* Callback signature for model.walkPaths().
*/
interface IModelPathCallback {
(modelContext: IModel, pathId: string, pathContext: IPath): void;
}
/**
* Test to see if an object implements the required properties of a model.
*/
@@ -408,6 +445,7 @@ declare module MakerJs.point {
*
* @param a First point.
* @param b Second point.
* @param accuracy Optional exemplar of number of decimal places.
* @returns true if points are the same, false if they are not
*/
function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean;
@@ -456,7 +494,7 @@ declare module MakerJs.point {
*/
function fromPathEnds(pathContext: IPath): IPoint[];
/**
* Get the middle point of a path. Currently only supports Arc and Line paths.
* Get the middle point of a path.
*
* @param pathContext The path object.
* @param ratio Optional ratio (between 0 and 1) of point along the path. Default is .5 for middle.
@@ -472,6 +510,14 @@ declare module MakerJs.point {
* @returns Mirrored point.
*/
function mirror(pointToMirror: IPoint, mirrorX: boolean, mirrorY: boolean): IPoint;
/**
* Round the values of a point.
*
* @param pointContext The point to serialize.
* @param accuracy Optional exemplar number of decimal places.
* @returns A new point with the values rounded.
*/
function rounded(pointContext: IPoint, accuracy?: number): IPoint;
/**
* Rotate a point.
*
@@ -489,6 +535,14 @@ declare module MakerJs.point {
* @returns A new point.
*/
function scale(pointToScale: IPoint, scaleValue: number): IPoint;
/**
* Get a string representation of a point.
*
* @param pointContext The point to serialize.
* @param accuracy Optional exemplar of number of decimal places.
* @returns String representing the point.
*/
function serialize(pointContext: IPoint, accuracy?: number): string;
/**
* Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true).
*
@@ -637,6 +691,13 @@ declare module MakerJs.paths {
}
}
declare module MakerJs.model {
/**
* Count the number of child models within a given model.
*
* @param modelContext The model containing other models.
* @returns Number of child models.
*/
function countChildModels(modelContext: IModel): number;
/**
* Get an unused id in the paths map with the same prefix.
*
@@ -702,12 +763,6 @@ declare module MakerJs.model {
* @returns The scaled model (for chaining).
*/
function convertUnits(modeltoConvert: IModel, destUnitType: string): IModel;
/**
* Callback signature for walkPaths.
*/
interface IModelPathCallback {
(modelContext: IModel, pathId: string, pathContext: IPath): void;
}
/**
* Recursively walk through all paths for a given model.
*
@@ -717,6 +772,15 @@ declare module MakerJs.model {
function walkPaths(modelContext: IModel, callback: IModelPathCallback): void;
}
declare module MakerJs.model {
/**
* Check to see if a path is inside of a model.
*
* @param pathContext The path to check.
* @param modelContext The model to check against.
* @param farPoint Optional point of reference which is outside the bounds of the modelContext.
* @returns Boolean true if the path is inside of the modelContext.
*/
function isPathInsideModel(pathContext: IPath, modelContext: IModel, farPoint?: IPoint): boolean;
/**
* Combine 2 models. The models should be originated.
*
@@ -726,9 +790,10 @@ declare module MakerJs.model {
* @param includeAOutsideB Flag to include paths from modelA which are outside of modelB.
* @param includeBInsideA Flag to include paths from modelB which are inside of modelA.
* @param includeBOutsideA Flag to include paths from modelB which are outside of modelA.
* @param keepDuplicates Flag to include paths which are duplicate in both models.
* @param farPoint Optional point of reference which is outside the bounds of both models.
*/
function combine(modelA: IModel, modelB: IModel, includeAInsideB: boolean, includeAOutsideB: boolean, includeBInsideA: boolean, includeBOutsideA: boolean, farPoint?: IPoint): void;
function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, keepDuplicates?: boolean, farPoint?: IPoint): void;
}
declare module MakerJs.units {
/**
@@ -927,7 +992,7 @@ declare module MakerJs.path {
* @param line2 Second line to fillet, which will be modified to fit the fillet.
* @returns Arc path object of the new fillet.
*/
function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number): IPathArc;
function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc;
/**
* Adds a round corner to the inside angle between 2 paths. The paths must meet at one point.
*
@@ -935,7 +1000,7 @@ declare module MakerJs.path {
* @param path2 Second path to fillet, which will be modified to fit the fillet.
* @returns Arc path object of the new fillet.
*/
function fillet(path1: IPath, path2: IPath, filletRadius: number): IPathArc;
function fillet(path1: IPath, path2: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc;
}
declare module MakerJs.kit {
/**
@@ -998,6 +1063,22 @@ declare module MakerJs.kit {
*/
function getParameterValues(ctor: IKit): any[];
}
declare module MakerJs.model {
/**
* Find paths that have common endpoints and form loops.
*
* @param modelContext The model to search for loops.
* @param options Optional options object.
* @returns A new model with child models ranked according to their containment within other found loops. The paths of models will be IPathDirectionalWithPrimeContext.
*/
function findLoops(modelContext: IModel, options?: IFindLoopsOptions): IModel;
/**
* Remove all paths in a loop model from the model(s) which contained them.
*
* @param loopToDetach The model to search for loops.
*/
function detachLoop(loopToDetach: IModel): void;
}
declare module MakerJs.exporter {
/**
* Attributes for an XML tag.
@@ -1052,6 +1133,34 @@ declare module MakerJs.exporter {
toString(): string;
}
}
declare module MakerJs.exporter {
function toOpenJsCad(modelToExport: IModel, options?: IOpenJsCadOptions): string;
function toOpenJsCad(pathsToExport: IPath[], options?: IOpenJsCadOptions): string;
function toOpenJsCad(pathToExport: IPath, options?: IOpenJsCadOptions): string;
/**
* Executes a JavaScript string with the OpenJsCad engine - converts 2D to 3D.
*
* @param modelToExport Model object to export.
* @param options Export options object.
* @param options.extrusion Height of 3D extrusion.
* @param options.resolution Size of facets.
* @returns String of STL format of 3D object.
*/
function toSTL(modelToExport: IModel, options?: IOpenJsCadOptions): string;
/**
* OpenJsCad export options.
*/
interface IOpenJsCadOptions extends IFindLoopsOptions {
/**
* Optional depth of 3D extrusion.
*/
extrusion?: number;
/**
* Optional size of curve facets.
*/
facetSize?: number;
}
}
declare module MakerJs.exporter {
function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string;
function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string;
@@ -1118,6 +1227,12 @@ declare module MakerJs.models {
constructor(width: number, height: number, holeRadius: number);
}
}
declare module MakerJs.models {
class Dome implements IModel {
paths: IPathMap;
constructor(width: number, height: number, radius?: number);
}
}
declare module MakerJs.models {
class RoundRectangle implements IModel {
paths: IPathMap;
+167 -83
View File
@@ -5,90 +5,174 @@
//Mithril type definitions for Typescript
interface MithrilStatic {
(selector: string, attributes: Object, children?: any): MithrilVirtualElement;
(selector: string, children?: any): MithrilVirtualElement;
prop<T>(value?: T): (value?: T) => T;
prop<T>(promise: MithrilPromise<T>): MithrilPromiseProperty<T>;
withAttr(property: string, callback: (value: any) => void): (e: Event) => any;
module(rootElement: Node, module: MithrilModule): void;
trust(html: string): String;
render(rootElement: Element, children?: any): void;
render(rootElement: HTMLDocument, children?: any): void;
redraw: MithrilRedraw;
route: MithrilRoute;
request(options: MithrilXHROptions): MithrilPromise<any>;
deferred<T>(): MithrilDeferred<T>;
sync<T>(promises: MithrilPromise<T>[]): MithrilPromise<T>;
startComputation(): void;
endComputation(): void;
declare module _mithril {
interface MithrilStatic {
<T extends MithrilController>(selector: string, attributes: MithrilAttributes, ...children: Array<string|MithrilVirtualElement|MithrilComponent<T>>): MithrilVirtualElement;
<T extends MithrilController>(selector: string, ...children: Array<string|MithrilVirtualElement|MithrilComponent<T>>): MithrilVirtualElement;
prop<T>(promise: MithrilPromise<T>) : MithrilPromiseProperty<T>;
prop<T>(value: T): MithrilProperty<T>;
prop(): MithrilProperty<Object>; // might be that this should be Property<any>
withAttr(property: string, callback: (value: any) => void): (e: MithrilEvent) => any;
module<T extends MithrilController>(rootElement: Node, component: MithrilComponent<T>): T;
module<T extends MithrilController>(rootElement: Node): T;
mount<T extends MithrilController>(rootElement: Node, component: MithrilComponent<T>): T;
mount<T extends MithrilController>(rootElement: Node): T;
component<T extends MithrilController>(component: MithrilComponent<T>, ...args: Array<any>): MithrilComponent<T>
trust(html: string): string;
render(rootElement: Element|HTMLDocument): void;
render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement, forceRecreation?: boolean): void;
render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement[], forceRecreation?: boolean): void;
redraw: {
(force?: boolean): void;
strategy: MithrilProperty<string>;
}
route: {
<T extends MithrilController>(rootElement: HTMLDocument, defaultRoute: string, routes: MithrilRoutes<T>): void;
<T extends MithrilController>(rootElement: Element, defaultRoute: string, routes: MithrilRoutes<T>): void;
(element: Element, isInitialized: boolean, context: Object, vdom: Object): void;
(path: string, params?: any, shouldReplaceHistory?: boolean): void;
(): string;
param(key: string): string;
mode: string;
buildQueryString(data: Object): String
parseQueryString(data: String): Object
}
request<T>(options: MithrilXHROptions): MithrilPromise<T>;
deferred: {
onerror(e: Error): void;
<T>(): MithrilDeferred<T>;
}
sync<T>(promises: MithrilPromise<T>[]): MithrilPromise<T[]>;
startComputation(): void;
endComputation(): void;
// For test suite
deps: {
(mockWindow: Window): Window;
factory: Object;
}
}
export interface MithrilVirtualElement {
key?: number;
tag?: string;
attrs?: MithrilAttributes;
children?: any[];
}
// Configuration function for an element
interface MithrilElementConfig {
(element: Element, isInitialized: boolean, context?: any, vdom?: MithrilVirtualElement): void;
}
// Attributes on a virtual element
interface MithrilAttributes {
title?: string;
className?: string;
class?: string;
config?: MithrilElementConfig;
}
// Defines the subset of Event that Mithril needs
interface MithrilEvent {
currentTarget: Element;
}
interface MithrilController {
onunload?(evt: Event): any;
}
interface MithrilControllerFunction extends MithrilController {
(): any;
}
interface MithrilView<T extends MithrilController> {
(ctrl: T): string|MithrilVirtualElement;
}
interface MithrilComponent<T extends MithrilController> {
controller: MithrilControllerFunction|{ new(): T };
view: MithrilView<T>;
}
interface MithrilProperty<T> {
(): T;
(value: T): T;
toJSON(): T;
}
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
(): T;
(value: T): T;
toJSON(): T;
}
interface MithrilRoutes<T extends MithrilController> {
[key: string]: MithrilComponent<T>;
}
interface MithrilDeferred<T> {
resolve(value?: T): void;
reject(value?: any): void;
promise: MithrilPromise<T>;
}
interface MithrilSuccessCallback<T, U> {
(value: T): U;
(value: T): MithrilPromise<U>;
}
interface MithrilErrorCallback<U> {
(value: Error): U;
(value: string): U;
}
interface MithrilPromise<T> {
(): T;
(value: T): T;
then<U>(success: (value: T) => U): MithrilPromise<U>;
then<U>(success: (value: T) => MithrilPromise<U>): MithrilPromise<U>;
then<U,V>(success: (value: T) => U, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
then<U,V>(success: (value: T) => MithrilPromise<U>, error: (value: Error) => V): MithrilPromise<U>|MithrilPromise<V>;
}
interface MithrilXHROptions {
method?: string;
url: string;
user?: string;
password?: string;
data?: any;
background?: boolean;
unwrapSuccess?(data: any): any;
unwrapError?(data: any): any;
serialize?(dataToSerialize: any): string;
deserialize?(dataToDeserialize: string): any;
extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string;
type?(data: Object): void;
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
dataType?: string;
}
}
interface MithrilRoute {
(rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
(rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void;
(path: string, params?: any, shouldReplaceHistory?: boolean): void;
(element: Element, isInitialized: boolean): void;
(): string;
mode: string;
param: MithrilParam;
buildQueryString(data: Object): string;
parseQueryString(queryString: string): Object;
}
declare var Mithril: _mithril.MithrilStatic;
declare var m: _mithril.MithrilStatic;
interface MithrilParam {
(param: string): string;
declare module "mithril" {
export = m;
}
interface MithrilRedraw {
(): void;
strategy: (value?: string) => string;
}
interface MithrilVirtualElement {
tag: string;
attrs: Object;
children: any;
}
interface MithrilModule {
controller: Function;
view: (controller?: any) => MithrilVirtualElement;
}
interface MithrilDeferred<T> {
resolve(value?: T): void;
reject(value?: any): void;
promise: MithrilPromise<T>;
}
interface MithrilPromise<T> {
(value?: T): T;
then<R>(successCallback?: (value: T) => R, errorCallback?: (value: any) => any): MithrilPromise<R>;
then<R>(successCallback?: (value: T) => MithrilPromise<R>, errorCallback?: (value: any) => any): MithrilPromise<R>;
}
interface MithrilPromiseProperty<T> extends MithrilPromise<T> {
(): T;
(value: T): T;
toJSON(): T;
}
interface MithrilXHROptions {
method: string;
url: string;
user?: string;
password?: string;
data?: any;
background?: boolean;
unwrapSuccess?(data: any): any;
unwrapError?(data: any): any;
serialize?(dataToSerialize: any): string;
deserialize?(dataToDeserialize: string): any;
extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string;
type?(data: Object): void;
config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest;
}
declare var Mithril: MithrilStatic;
declare var m: MithrilStatic;
+96 -6
View File
@@ -19,9 +19,9 @@ $(function () {
document.getElementById('#notice').innerHTML = msg;
}
Modernizr.prefixed('boxSizing');
Modernizr.prefixed('boxSizing');
Modernizr.prefixed('requestAnimationFrame', window);
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, document.body);
var ms = Modernizr.prefixed("matchesSelector", HTMLElement.prototype, true);
Modernizr.prefixed('requestAnimationFrame', window, false);
Modernizr.mq('only all and (max-width: 400px)');
@@ -30,7 +30,7 @@ $(function () {
Modernizr.addTest('track', () => {
var video = document.createElement('video');
// return typeof video.addTextTrack === 'function'
return typeof video.addTextTrack === 'function'
});
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
@@ -45,10 +45,100 @@ $(function () {
Modernizr.testAllProps('boxSizing');
var elem;
var elem: Element;
Modernizr.hasEvent('gesturestart', elem);
if (!Modernizr.autofocus) {
if (!Modernizr.input.autofocus) {
$("[autofocus]").focus();
}
});
Modernizr.on('flash', function( result ) {
if (result) {
// the browser has flash
} else {
// the browser does not have flash
}
});
Modernizr.addTest('itsTuesday', function() {
var d = new Date();
return d.getDay() === 2;
});
Modernizr.addTest('hasJquery', 'jQuery' in window);
var detects = {
'hasjquery': 'jQuery' in window,
'itstuesday': function() {
var d = new Date();
return d.getDay() === 2;
}
}
Modernizr.addTest(detects);
var keyframes = Modernizr.atRule('@keyframes');
if (keyframes) {
// keyframes are supported
// could be `@-webkit-keyframes` or `@keyframes`
} else {
// keyframes === `false`
}
Modernizr._domPrefixes === [ "Moz", "O", "ms", "Webkit" ];
Modernizr.hasEvent('blur') // true;
Modernizr.hasEvent('devicelight', window) // true;
var query = Modernizr.mq('(min-width: 900px)');
if (query) {
// the browser window is larger than 900px
}
Modernizr.prefixed('boxSizing')
var raf = Modernizr.prefixed('requestAnimationFrame', window);
raf(function() {
});
var rAFProp = Modernizr.prefixed('requestAnimationFrame', window, false);
rAFProp === 'WebkitRequestAnimationFrame' // in older webkit
Modernizr.prefixedCSS('transition') // '-moz-transition' in old Firefox
Modernizr.prefixedCSSValue('background', 'linear-gradient(left, red, red)')
var rule = Modernizr._prefixes.join('transform: rotate(20deg); ');
rule === 'transform: rotate(20deg); webkit-transform: rotate(20deg); moz-transform: rotate(20deg); o-transform: rotate(20deg); ms-transform: rotate(20deg);'
rule = 'display:' + Modernizr._prefixes.join('flex; display:') + 'flex';
rule === 'display:flex; display:-webkit-flex; display:-moz-flex; display:-o-flex; display:-ms-flex; display:flex'
Modernizr.testAllProps('boxSizing') // true
Modernizr.testAllProps('display', 'block') // true
Modernizr.testAllProps('display', 'penguin') // false
Modernizr.testAllProps('shapeOutside', 'content-box', true);
Modernizr.testProp('pointerEvents') // true
Modernizr.testProp('pointerEvents', 'none') // true
Modernizr.testProp('pointerEvents', 'penguin') // false
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', function(elem, rule) {
// elem is the first DOM node in the page (by default #modernizr)
// rule is the first argument you supplied - the CSS rule in string form
Modernizr.addTest('widthworks', elem.style.width === '9px')
});
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
document.getElementById('modernizr').style.width === '1px'; // true
document.getElementById('modernizr2').style.width === '2px'; // true
elem.firstChild === document.getElementById('modernizr2'); // true
}, 1);
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
document.getElementById('modernizr').style.width === '1px'; // true
document.getElementById('modernizr2').style.width === '2px'; // true
elem.firstChild === document.getElementById('modernizr2'); // true
}, 1);
-1
View File
@@ -1 +0,0 @@
+374 -111
View File
@@ -1,116 +1,379 @@
// Type definitions for Modernizr 2.6.2
// Type definitions for Modernizr 3.2.0
// Project: http://modernizr.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb/>, Leon Yu <https://github.com/leonyu/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace __Modernizr {
interface AudioBoolean {
ogg: boolean;
mp3: boolean;
wav: boolean;
m4a: boolean;
}
interface Audioboolean {
ogg: boolean;
mp3: boolean;
wav: boolean;
m4a: boolean;
interface VideoBoolean {
ogg: boolean;
h264: boolean;
webm: boolean;
}
interface InputBoolean {
autocomplete: boolean;
autofocus: boolean;
list: boolean;
placeholder: boolean;
max: boolean;
min: boolean;
multiple: boolean;
pattern: boolean;
required: boolean;
step: boolean;
}
interface InputTypesBoolean {
color: boolean;
date: boolean;
datetime: boolean;
"datetime-local": boolean;
email: boolean;
month: boolean;
number: boolean;
range: boolean;
search: boolean;
tel: boolean;
time: boolean;
url: boolean;
week: boolean;
}
interface FeatureDetects {
// Documented
ambientlight: boolean;
applicationcache: boolean;
audio: AudioBoolean;
batteryapi: boolean;
blobconstructor: boolean;
canvas: boolean;
canvastext: boolean;
contenteditable: boolean;
contextmenu: boolean;
cookies: boolean;
cors: boolean;
cryptography: boolean;
customprotocolhandler: boolean;
customevent: boolean;
dart: boolean;
dataview: boolean;
emoji: boolean;
eventlistener: boolean;
exiforientation: boolean;
flash: boolean;
forcetouch: boolean;
fullscreen: boolean;
gamepads: boolean;
geolocation: boolean;
hashchange: boolean;
hiddenscroll: boolean;
history: boolean;
htmlimports: boolean;
ie8compat: boolean;
indexeddb: boolean;
indexeddbblob: boolean;
input: InputBoolean;
search: boolean;
inputtypes: InputTypesBoolean;
intl: boolean;
json: boolean;
ligatures: boolean;
olreversed: boolean;
mathml: boolean;
notification: boolean;
pagevisibility: boolean;
performance: boolean;
pointerevents: boolean;
pointerlock: boolean;
postmessage: boolean;
proximity: boolean;
queryselector: boolean;
quotamanagement: boolean;
requestanimationframe: boolean;
serviceworker: boolean;
svg: boolean;
templatestrings: boolean;
touchevents: boolean;
typedarrays: boolean;
unicoderange: boolean;
unicode: boolean;
userdata: boolean;
vibrate: boolean;
video: VideoBoolean;
vml: boolean;
webintents: boolean;
animation: boolean;
webgl: boolean;
websockets: boolean;
xdomainrequest: boolean;
adownload: boolean;
audioloop: boolean;
audiopreload: boolean;
webaudio: boolean;
lowbattery: boolean;
canvasblending: boolean;
todataurljpeg: boolean;
todataurlpng: boolean;
todataurlwebp: boolean;
canvaswinding: boolean;
getrandomvalues: boolean;
cssall: boolean;
cssanimations: boolean;
appearance: boolean;
backdropfilter: boolean;
backgroundblendmode: boolean;
backgroundcliptext: boolean;
bgpositionshorthand: boolean;
bgpositionxy: boolean;
bgrepeatspace: boolean;
bgrepeatround: boolean;
backgroundsize: boolean;
bgsizecover: boolean;
borderimage: boolean;
borderradius: boolean;
boxshadow: boolean;
boxsizing: boolean;
csscalc: boolean;
checked: boolean;
csschunit: boolean;
csscolumns: boolean;
cubicbezierrange: boolean;
"display-runin": boolean;
displaytable: boolean;
ellipsis: boolean;
cssescape: boolean;
cssexunit: boolean;
cssfilters: boolean;
flexbox: boolean;
flexboxlegacy: boolean;
flexboxtweener: boolean;
flexwrap: boolean;
fontface: boolean;
generatedcontent: boolean;
cssgradients: boolean;
csshairline: boolean;
hsla: boolean;
csshyphens: boolean;
softhyphens: boolean;
softhyphensfind: boolean;
cssinvalid: boolean;
lastchild: boolean;
cssmask: boolean;
mediaqueries: boolean;
multiplebgs: boolean;
nthchild: boolean;
objectfit: boolean;
opacity: boolean;
overflowscrolling: boolean;
csspointerevents: boolean;
csspositionsticky: boolean;
csspseudoanimations: boolean;
csspseudotransitions: boolean;
cssreflections: boolean;
regions: boolean;
cssremunit: boolean;
cssresize: boolean;
rgba: boolean;
cssscrollbar: boolean;
scrollsnappoints: boolean;
shapes: boolean;
siblinggeneral: boolean;
subpixelfont: boolean;
supports: boolean;
target: boolean;
textalignlast: boolean;
textshadow: boolean;
csstransforms: boolean;
csstransforms3d: boolean;
preserve3d: boolean;
csstransitions: boolean;
userselect: boolean;
cssvalid: boolean;
cssvhunit: boolean;
cssvmaxunit: boolean;
cssvminunit: boolean;
cssvwunit: boolean;
willchange: boolean;
wrapflow: boolean;
classlist: boolean;
createelementattrs: boolean;
"createelement-attrs": boolean;
dataset: boolean;
documentfragment: boolean;
hidden: boolean;
microdata: boolean;
mutationobserver: boolean;
bdi: boolean;
datalistelem: boolean;
details: boolean;
outputelem: boolean;
picture: boolean;
progressbar: boolean;
meter: boolean;
ruby: boolean;
template: boolean;
time: boolean;
texttrackapi: boolean;
track: boolean;
unknownelements: boolean;
es5array: boolean;
es5date: boolean;
es5function: boolean;
es5object: boolean;
es5: boolean;
strictmode: boolean;
es5string: boolean;
es5syntax: boolean;
es5undefined: boolean;
es6array: boolean;
es6collections: boolean;
contains: boolean;
generators: boolean;
es6math: boolean;
es6number: boolean;
es6object: boolean;
promises: boolean;
es6string: boolean;
devicemotion: boolean;
deviceorientation: boolean;
oninput: boolean;
filereader: boolean;
filesystem: boolean;
capture: boolean;
fileinput: boolean;
directory: boolean;
formattribute: boolean;
localizednumber: boolean;
placeholder: boolean;
requestautocomplete: boolean;
formvalidation: boolean;
sandbox: boolean;
seamless: boolean;
srcdoc: boolean;
apng: boolean;
imgcrossorigin: boolean;
jpeg2000: boolean;
jpegxr: boolean;
sizes: boolean;
srcset: boolean;
webpalpha: boolean;
webpanimation: boolean;
webplossless: boolean;
"webp-lossless": boolean;
webp: boolean;
inputformaction: boolean;
inputformenctype: boolean;
inputformmethod: boolean;
inputformtarget: boolean;
beacon: boolean;
lowbandwidth: boolean;
eventsource: boolean;
fetch: boolean;
xhrresponsetypearraybuffer: boolean;
xhrresponsetypeblob: boolean;
xhrresponsetypedocument: boolean;
xhrresponsetypejson: boolean;
xhrresponsetypetext: boolean;
xhrresponsetype: boolean;
xhr2: boolean;
scriptasync: boolean;
scriptdefer: boolean;
speechrecognition: boolean;
speechsynthesis: boolean;
localstorage: boolean;
sessionstorage: boolean;
websqldatabase: boolean;
stylescoped: boolean;
svgasimg: boolean;
svgclippaths: boolean;
svgfilters: boolean;
svgforeignobject: boolean;
inlinesvg: boolean;
smil: boolean;
textareamaxlength: boolean;
bloburls: boolean;
datauri: boolean;
urlparser: boolean;
videoautoplay: boolean;
videoloop: boolean;
videopreload: boolean;
webglextensions: boolean;
datachannel: boolean;
getusermedia: boolean;
peerconnection: boolean;
websocketsbinary: boolean;
atobbtoa: boolean;
framed: boolean;
matchmedia: boolean;
blobworkers: boolean;
dataworkers: boolean;
sharedworkers: boolean;
transferables: boolean;
webworkers: boolean;
// Undocumented - usually aliases or new features
"atob-btoa": boolean;
"battery-api": boolean;
"blob-constructor": boolean;
"display-table": boolean;
"input-formaction": boolean;
"input-formenctype": boolean;
"input-formtarget": boolean;
"object-fit": boolean;
crypto: boolean;
displayrunin: boolean;
fileinputdirectory: boolean;
hairline: boolean;
inputsearchevent: boolean;
raf: boolean;
webanimations: boolean;
}
interface Dictionary<T> {
[key: string]: T;
}
interface ModernizrAPI {
on(feature: string, cb: (result: boolean) => any): void;
addTest(feature: string, test: () => boolean): void;
addTest(feature: string, test: boolean): void;
addTest(feature: Dictionary<any>): void;
atRule(prop: string): boolean;
_domPrefixes: string[];
hasEvent(eventName: string, element?: EventTarget): boolean;
mq(mq: string): boolean;
prefixed(prop: string): string;
prefixed(prop: string, obj: EventTarget, element?: boolean): any;
prefixedCSS(prop: string): string;
prefixedCSSValue(prop: string, value: string): string;
_prefixes: string[];
testAllProps(prop: string, value?: string, skipValueTest?: boolean): boolean;
testProp(prop: string, value?: string, useValue?: boolean): boolean;
testStyles(rule: string, callback: (elem: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean;
}
export interface ModernizrStatic extends ModernizrAPI, FeatureDetects { }
}
interface Videoboolean {
ogg: boolean;
h264: boolean;
webm: boolean;
}
interface Inputboolean {
autocomplete: boolean;
autofocus: boolean;
list: boolean;
placeholder: boolean;
max: boolean;
min: boolean;
multiple: boolean;
pattern: boolean;
required: boolean;
step: boolean;
}
interface InputTypesboolean {
search: boolean;
tel: boolean;
url: boolean;
email: boolean;
datetime: boolean;
date: boolean;
month: boolean;
week: boolean;
time: boolean;
datetimelocal: boolean;
number: boolean;
range: boolean;
color: boolean;
}
interface ModernizrStatic {
autofocus: boolean;
fontface: boolean;
backgroundsize: boolean;
borderimage: boolean;
borderradius: boolean;
boxshadow: boolean;
flexbox: boolean;
hsla: boolean;
multiplebgs: boolean;
opacity: boolean;
rgba: boolean;
textshadow: boolean;
cssanimations: boolean;
csscolumns: boolean;
generatedcontent: boolean;
cssgradients: boolean;
cssreflections: boolean;
csstransforms: boolean;
csstransforms3d: boolean;
csstransitions: boolean;
applicationcache: boolean;
canvas: boolean;
canvastext: boolean;
draganddrop: boolean;
hashchange: boolean;
history: boolean;
audio: Audioboolean;
video: Videoboolean;
indexeddb: boolean;
input: Inputboolean;
inputtypes: InputTypesboolean;
localstorage: boolean;
postmessage: boolean;
sessionstorage: boolean;
websockets: boolean;
websqldatabase: boolean;
webworkers: boolean;
geolocation: boolean;
inlinesvg: boolean;
smil: boolean;
svg: boolean;
svgclippaths: boolean;
touch: boolean;
webgl: boolean;
load(resources: any[]): void;
load(resourceObject: any): void;
load(resourceString: string): void;
prefixed(property: string): any;
prefixed(property: string, obj: any, element?: any): any;
mq(mediaQuery: string): boolean;
addTest(feature: string, test: () => any): void;
addTest(feature: string, test: boolean): void;
addTest(feature: any): void;
testStyles(rule: string, callback: (element: HTMLDivElement, rule: string) => void, nodes?: number, testnames?: string[]): boolean;
testProp(property: string): boolean;
testAllProps(property: string, prefix?: string): boolean;
testAllProps(property: string, obj: any, element: any): boolean;
hasEvent(eventName: string, element?: any): boolean;
}
declare var Modernizr: ModernizrStatic;
declare var Modernizr: __Modernizr.ModernizrStatic;
+2
View File
@@ -20,6 +20,8 @@ class DialogTestController {
template: "login.html",
className: "default flat-ui",
closeByEscape: false,
data: "string",
disableAnimation: false,
name: "login-popup"
});
+10
View File
@@ -61,6 +61,12 @@ declare module angular.dialog {
* It will be appended with the "ngdialog" class e.g. className is "default-theme flat-ui" it will be class="ngdialog default-theme flat-ui".
*/
className?: string;
/**
* If true then animation for the dialog will be disabled, default false.
*/
disableAnimation?: boolean;
/**
* If false it allows to hide overlay div behind the modals, default true.
*/
@@ -106,5 +112,9 @@ declare module angular.dialog {
* Scope object that will be passed to dialog. If you use controller with separate $scope service this object will be passed to $scope.$parent param.
*/
scope?: ng.IScope;
/**
* Any serializable data that you want to be stored in the controller's dialog scope.
*/
data?: string|Object|any[];
}
}
+11
View File
@@ -0,0 +1,11 @@
/// <reference path='../angularjs/angular.d.ts'/>
/// <reference path="ng-notify.d.ts" />
class NgNotifyTestController {
static $inject = ['$scope', 'ngNotify'];
constructor($scope:ng.IScope, ngNotify:ngNotify.INotifyService) {
ngNotify.set('Your error message goes here!', 'error');
}
};
+72
View File
@@ -0,0 +1,72 @@
// Type definitions for ng-notify 0.7.1
// Project: https://github.com/matowens/ng-notify
// Definitions by: Nick Zamosenchuk <https://github.com/nzamosenchuk>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../angularjs/angular.d.ts'/>
declare module ngNotify {
/**
* Contains the options used to configure notification.
*/
interface IUserOptions{
type?: string;
theme?: string;
position?: string;
duration?: number;
sticky?: boolean;
button?: boolean;
html?: boolean;
}
/**
* Simply and lightweight notification service for AngularJS
*/
interface INotifyService {
/**
* Allows to create a whole new set of styles for each notification type.
* @param themeName The name used when setting the theme in the config object.
* @param className The class used to target this theme in the stylesheet.
*/
addTheme(themeName:string, className:string):void;
/**
* Allows to create a new type of notification to use in their app.
* @param typeName The name used to trigger this notification type in the set method.
* @param className The class used to target this type in the stylesheet.
*/
addType(typeName:string, className:string):void;
/**
* Sets default settings for all notifications to take into account when displaying.
* @param userOptions Notification configuration object
*/
config(userOptions: IUserOptions):void;
/**
* Manually dismisses any sticky notifications that may still be set.
*/
dismiss():void;
/**
* Displays a notification message.
* @param message A message text to display.
*/
set(message: string):void;
/**
* Displays a notification message and sets the type for this one notification.
* @param message A message text to display.
* @param type The type of the notification.
*/
set(message: string, type: string):void;
/**
* displays a notification message and sets the formatting/behavioral options for this one notification.
* @param message A message text to display.
* @param userOptions Notification configuration object.
*/
set(message: string, userOptions: IUserOptions):void;
}
}
+4 -4
View File
@@ -221,22 +221,22 @@ interface PDFPageProxy {
/**
* Page number of the page. First page is 1.
**/
pageNumber(): number;
pageNumber: number;
/**
* The number of degrees the page is rotated clockwise.
**/
rotate(): number;
rotate: number;
/**
* The reference that points to this page.
**/
ref(): PDFRef;
ref: PDFRef;
/**
* @return An array of the visible portion of the PDF page in the user space units - [x1, y1, x2, y2].
**/
view(): number[];
view: number[];
/**
* @param scale The desired scale of the viewport.
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="./polymer-ts.d.ts"/>
namespace Components {
export class TestComponent extends polymer.Base {
public field: string = 'foo';
public is: string;
constructor() {
super();
this.is = 'test-test';
}
public ready(): void {
console.log('ready');
this.async(() => {
console.log('delayed');
}, 500);
}
}
polymer.createElement(TestComponent);
}
+132
View File
@@ -0,0 +1,132 @@
// Type definitions for PolymerTS 0.1.19
// Project: https://github.com/nippur72/PolymerTS
// Definitions by: Louis Grignon <https://github.com/lgrignon/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module polymer {
class PolymerBase extends HTMLElement {
$: any;
$$: any;
root: HTMLElement;
shadyRoot: HTMLElement;
style: CSSStyleDeclaration;
customStyle: {
[property: string]: string;
};
arrayDelete(path: string, item: string | any): any;
async(callback: Function, waitTime?: number): any;
attachedCallback(): void;
attributeFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void;
cancelAsync(handle: number): void;
cancelDebouncer(jobName: string): void;
classFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void;
create(tag: string, props: Object): any;
debounce(jobName: string, callback: Function, wait?: number): void;
deserialize(value: string, type: any): any;
distributeContent(): void;
domHost(): void;
elementMatches(selector: string, node: Element): any;
fire(type: string, detail?: Object, options?: FireOptions): any;
flushDebouncer(jobName: string): void;
get(path: string | Array<string | number>): any;
getContentChildNodes(slctr: string): any;
getContentChildren(slctr: string): any;
getNativePrototype(tag: string): any;
getPropertyInfo(property: string): any;
importHref(href: string, onload?: Function, onerror?: Function): any;
instanceTemplate(template: any): any;
isDebouncerActive(jobName: string): any;
linkPaths(to: string, from: string): void;
listen(node: Element, eventName: string, methodName: string): void;
mixin(target: Object, source: Object): void;
notifyPath(path: string, value: any, fromAbove?: any): void;
pop(path: string): any;
push(path: string, value: any): any;
reflectPropertyToAttribute(name: string): void;
resolveUrl(url: string): any;
scopeSubtree(container: Element, shouldObserve: boolean): void;
serialize(value: string): any;
serializeValueToAttribute(value: any, attribute: string, node: Element): void;
set(path: string, value: any, root?: Object): any;
setScrollDirection(direction: string, node: HTMLElement): void;
shift(path: string, value: any): any;
splice(path: string, start: number, deleteCount: number): any;
toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void;
toggleClass(name: string, bool: boolean, node?: HTMLElement): void;
transform(transform: string, node?: HTMLElement): void;
translate3d(x: any, y: any, z: any, node?: HTMLElement): void;
unlinkPaths(path: string): void;
unshift(path: string, value: any): any;
updateStyles(): void;
}
interface dom {
(node: HTMLElement): HTMLElement;
(node: polymer.Base): HTMLElement;
flush(): any;
}
interface FireOptions {
node?: HTMLElement | polymer.Base;
bubbles?: boolean;
cancelable?: boolean;
}
interface Element {
properties?: Object;
listeners?: Object;
behaviors?: Object[];
observers?: String[];
factoryImpl?(...args: any[]): void;
ready?(): void;
created?(): void;
attached?(): void;
detached?(): void;
attributeChanged?(attrName: string, oldVal: any, newVal: any): void;
prototype?: Object;
}
interface PolymerTSElement {
$custom_cons?: FunctionConstructor;
$custom_cons_args?: any[];
template?: string;
style?: string;
}
interface Property {
name?: string;
type?: any;
value?: any;
reflectToAttribute?: boolean;
readOnly?: boolean;
notify?: boolean;
computed?: string;
observer?: string;
}
class Base extends polymer.PolymerBase implements polymer.Element {
static create<T extends polymer.Base>(...args: any[]): T;
static register(): void;
is: string;
}
function createEs6PolymerBase(): void;
function prepareForRegistration(elementClass: Function): polymer.Element;
function createDomModule(definition: polymer.Element): void;
function createElement<T extends polymer.Base>(element: new (...args: any[]) => T): new (...args: any[]) => T;
function createClass<T extends polymer.Base>(element: new (...args: any[]) => T): new (...args: any[]) => T;
function isRegistered(element: polymer.Element): boolean;
}
declare var Polymer: {
(prototype: polymer.Element): FunctionConstructor;
Class(prototype: polymer.Element): Function;
dom: polymer.dom;
appendChild(node: HTMLElement): HTMLElement;
insertBefore(node: HTMLElement, beforeNode: HTMLElement): HTMLElement;
removeChild(node: HTMLElement): HTMLElement;
updateStyles(): void;
Base: any;
};
declare function component(tagname: string, extendsTag?: string): (target: Function) => void;
declare function extend(tagname: string): (target: Function) => void;
declare function template(templateString: string): (target: Function) => void;
declare function style(styleString: string): (target: Function) => void;
declare function hostAttributes(attributes: Object): (target: Function) => void;
declare function property(ob?: polymer.Property): (target: polymer.Element, propertyKey: string) => void;
declare function computed(ob?: polymer.Property): (target: polymer.Element, computedFuncName: string) => void;
declare function listen(eventName: string): (target: polymer.Element, propertyKey: string) => void;
declare function behavior(behaviorObject: any): any;
declare function observe(observedProps: string): (target: polymer.Element, observerFuncName: string) => void;
+82
View File
@@ -0,0 +1,82 @@
/// <reference path="../es6-promise/es6-promise.d.ts"/>
/// <reference path="./react-datagrid.d.ts" />
/// <reference path="../react/react.d.ts" />
import * as React from "react";
import ReactDataGrid = require("react-datagrid");
var data: any[] = [];
var columns: ReactDataGrid.Column[] = [
{ name: 'index', title: '#', width: 50 },
{ name: 'firstName', style: { color: 'red' }, visible: true},
{ name: 'lastName', render: (v) => {return v + " Phd"}},
{ name: 'city', textAlign: 'right', defaultVisible: true},
{ name: 'email', defaultHidden: true }
];
var selected = {};
var sortInfo: ReactDataGrid.SortInfo[] = [ { name: 'country', dir: 'asc'}]
export module X {
export class ExampleBasic extends React.Component<{},{}> {
render(): React.ReactElement<any> {
return (
<ReactDataGrid
key={0}
ref='dlgBasic'
idProperty='id'
dataSource={data}
columns={columns}/>
);
}
}
}
class ExampleFull extends React.Component<{},{}> {
render(): React.ReactElement<any> {
return (
<ReactDataGrid
key={1}
ref='dlgFull'
idProperty='id'
dataSource={data}
columns={columns}
style={{height: 500}}
withColumnMenu={false}
selected={selected}
sortInfo={sortInfo}
groupBy={['country','grade']}
liveFilter={true}
emptyText={'No records'}
loading={true}
loadMaskOverHeader={false}
rowStyle={{color: 'blue'}}
showCellBorders="vertical"
rowHeight={50}
defaultPageSize={110}
paginationToolbarProps={{
pageSizes: [100, 1000,2000],
showPageSize: false,
showRefreshIcon: false,
iconSize: 30,
iconProps: {
style: {fill: '#FF8484'},
overStyle: {fill: 'red'},
disabledStyle: { fill: '#808080'}
}
}}
pagination={true}
page={1}
pageSize={100}
onPageChange={(page: number) => {}}
onPageSizeChange={(pageSize: number, props: ReactDataGrid.DataGridProps) => {}}
onColumnOrderChange={(index: number, dropIndex: number) => {}}
onColumnResize={(firstCol: ReactDataGrid.Column, firstSize: number, secondCol: ReactDataGrid.Column, secondSize: number) => {}}
onSelectionChange={(newSelectedId: string, data: any) => {}}
onSortChange={(sortInfo: ReactDataGrid.SortInfo[]) => {}}
onFilter={(column: ReactDataGrid.Column, value: any, allFilterValues: any[]) => {} }
/>
);
}
}
+311
View File
@@ -0,0 +1,311 @@
// Type definitions for react-datagrid 1.2.15
// Project: https://github.com/zippyui/react-datagrid.git
// Definitions by: Stephen Jelfs <https://github.com/stephenjelfs>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../react/react.d.ts"/>
/// <reference path="../es6-promise/es6-promise.d.ts"/>
declare module "react-datagrid" {
import DataGrid = ReactDataGrid.DataGrid;
export = DataGrid;
}
declare namespace ReactDataGrid {
import React = __React;
interface DataGridProps extends React.Props<DataGrid> {
/**
* Array/String/Function/Promise - for local data, an array of object
* to render in the grid. For remote data, a string url, or a function
* that returns a promise.
*/
dataSource: any[] | string | ((query: {pageSize: number, skip: number}) => Promise<any[]>);
dataSourceCount?: number;
/**
* String - the name of the property where the id is found for each
* object in the data array.
*/
idProperty: string;
/**
* Array - an array of columns that are going to be rendered in the
* grid.
*/
columns: Column[];
/**
* Sorting the data array is not done by the grid. You can however
* pass in sort info so the grid renders with sorting icons as needed.
*/
onSortChange?: (sortInfo: SortInfo[]) => void;
/**
* Array - an array with sorting information.
*/
sortInfo?: SortInfo[];
style?: __React.CSSProperties;
/**
* Object/Function - you can specify either a style object to be
* applied to all rows, or a function. The function is called with
* (data, props) (so you have access to props.index for example) and
* is expected to return a style object.
*/
rowStyle?: __React.CSSProperties | ((data: any, props: RowProps) => React.CSSProperties);
/**
* Boolean - show a column menu to show/hide columns.
*/
withColumnMenu?: boolean;
/**
* If you want to enable column reordering, just specify the
* onColumnOrderChange prop on the grid:
*/
onColumnOrderChange?: (index: number, dropIndex: number) => void;
/**
* If you want to enable column resized, just specify the
* onColumnResize prop on the grid:
*/
onColumnResize?: (firstCol: Column, firstSize: number,
secondCol: Column, secondSize: number) => void;
/**
* If you want to enable selection, just specify the
* onSelectionChange prop on the grid:
*/
onSelectionChange?: (newSelected: {}, data: any) => void;
/**
* When a column is shown/hidden, you can be notified using the
* onColumnVisibilityChange callback prop.
*/
onColumnVisibilityChange?: (column: Column, visibility: boolean) => void;
/**
* The current selection.
*/
selected?: {};
/**
* Group rows by matching values.
*/
groupBy?: any[];
/**
* If you want to enable filter, just specify the
* onFilter prop on the grid:
*/
onFilter?: (column: Column, value: any, allFilterValues: any[]) => void;
/**
* To apply the filter while typing.
*/
liveFilter?: boolean;
/**
* Empty text for no records.
*/
emptyText?: string;
/**
* Loading grid.
*/
loading?: boolean;
/**
* If you dont want loadMask over header, specify
*/
loadMaskOverHeader?: boolean;
/**
* Show cell borders. Other valid values: 'horizontal', 'vertical'.
*/
showCellBorders?: boolean | string;
/**
* Custom row height.
*/
rowHeight?: number;
/**
* When you have remote data, pagination is setup by default. If you
* want to disable pagination, specify the pagination prop with a false
* value.
*/
pagination?: boolean;
defaultPageSize?: number;
defaultPage?: number;
/**
* Number - controlled alternative for defaultPageSize. When pageSize
* changes, onPageSizeChange(pageSize) is called.
*/
pageSize?: number;
/**
* Number - controlled alternative for defaultPage. When page changes,
* onPageChange(page) is called.
*/
page?: number;
/**
* Customize the pagination toolbar.
*/
paginationToolbarProps?: PaginationToolbarProps;
/**
* handle page changes.
*/
onPageChange?: (page: number) => void;
/**
* handle page size changes.
*/
onPageSizeChange?: (pageSize: number, props: DataGridProps) => void;
}
interface SortInfo {
name: string;
dir: string;
}
interface Column {
/**
* String - each column should have a name property.
*/
name: string;
/**
* String/ReactElement - a title to show in the header. If not
* specified, a humanized version of name will be used. Can be a string
* or anything that React can render, so you can customize it as you
* please.
*/
title?: string | React.ReactElement<any>;
/**
* Function - if you want custom rendering, specify this property.
*
* The column.render function is called with 3 args:
* value - the default value to be rendered (equals to data[column.name])
* data - the corresponding data object for the current row
cellProps - an object with props for the current cell
*/
render?: (value: any, data: any, cellProps: CellProps) => any;
/**
* Object - if you want cells in this column to be have a custom
* style.
*/
style?: __React.CSSProperties;
/**
* String - one of 'left', 'right', 'center'.
*/
textAlign?: string;
/**
* String - a className to be applied to all cells in this column
*/
className?: string;
width?: number;
minWidth?: number;
/**
* Columns are flexible via flexbox. Specify a flex property for this.
* Unless a column specifies a flex or a width property, it is assumed
* to have flex: 1.
*/
flex?: number;
/**
* Specify a column as visible/hidden.
*/
defaultVisible?: boolean;
defaultHidden?: boolean;
/**
* Boolean - controlled (which means you have to manually set column
* visibility when it changes, by using onColumnVisibilityChange).
*/
visible?: boolean;
}
interface CellProps {
/**
* the index of the row
*/
rowIndex: number;
/**
* the index of the column
*/
index: number;
/**
* a style for the cell
*/
style: React.CSSProperties;
/**
* a class name for the cell
*/
className: string;
}
interface RowProps {
/**
* the index of the row
*/
index: number;
/**
* a class name for the row when the mouse is over it
*/
overClassName: string;
/**
* a class name for the row when selected
*/
selectedClassName: string;
/**
* a class name for the row
*/
className: string;
}
interface PaginationToolbarProps {
/**
* Available page sizes.
*/
pageSizes: number[];
/**
* Hide/show page sizes.
*/
showPageSize: boolean;
/**
* Customize icons.
*/
showRefreshIcon: boolean;
iconSize: number;
iconProps: {
style: React.SVGAttributes,
overStyle: React.SVGAttributes,
disabledStyle: React.SVGAttributes
}
}
export class DataGrid extends __React.Component<DataGridProps, {}> {
}
}
+2
View File
@@ -92,12 +92,14 @@ server.put( '/hello', send);
server.del( '/hello', send);
server.get( '/hello', send);
server.head('/hello', send);
server.opts('/hello', send);
server.post(/(.*)/, send);
server.put( /(.*)/, send);
server.del( /(.*)/, send);
server.get( /(.*)/, send);
server.head(/(.*)/, send);
server.opts(/(.*)/, send);
new restify.BadRequestError();
+5
View File
@@ -87,6 +87,11 @@ declare module "restify" {
head(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[][]): any;
head(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[][]): any;
opts(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[]): any;
opts(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[]): any;
opts(route: any, routeCallBack: RequestHandler, ...routeCallBacks: RequestHandler[][]): any;
opts(route: any, routeCallBack: RequestHandler[], ...routeCallBacks: RequestHandler[][]): any;
name: string;
version: string;
log: Object;
+81
View File
@@ -0,0 +1,81 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="sql.js.d.ts" />
import fs = require("fs");
import SQL = require("sql.js");
var DB_PATH = "data.db";
function createFile(path: string): void {
var fd = fs.openSync(path, "a");
fs.closeSync(fd);
}
// Open the database file. If it does not exist, create a blank database in memory.
var databaseData: Buffer;
databaseData = fs.existsSync(DB_PATH) ? fs.readFileSync(DB_PATH) : null;
var db = new SQL.Database(databaseData);
// Create a new table 'test_table' in the database in memory.
var createTableStatement =
"DROP TABLE IF EXISTS test_table;" +
"CREATE TABLE test_table (id INTEGER PRIMARY KEY, content TEXT);";
db.run(createTableStatement);
// Insert 2 records for testing.
var insertRecordStatement =
"INSERT INTO test_table (id, content) VALUES (@id, @content);";
db.run(insertRecordStatement, {
"@id": 1,
"@content": "Content 1"
});
db.run(insertRecordStatement, {
"@id": 2,
"@content": "Content 2"
});
try {
// This query will throw exception: primary key constraint failed.
db.run(insertRecordStatement, {
"@id": 1,
"@content": "Content 3"
});
} catch (ex) {
console.warn(ex);
}
// A simple SELECT query.
var selectRecordStatement =
"SELECT * FROM test_table WHERE id = @id;"
var selectStatementObject = db.prepare(selectRecordStatement);
var results = selectStatementObject.get({
"@id": 1
});
console.log(results);
selectStatementObject.free();
// Access the results one by one, asynchronously.
var selectRecordsStatement =
"SELECT * FROM test_table;";
db.each(
selectRecordsStatement,
(obj: { [columnName: string]: number | string | Uint8Array }): void => {
console.log(obj);
},
(): void => {
console.info("Iteration done.");
dbAccessDone();
});
function dbAccessDone(): void {
// Save the database into SQLite version 3 format.
if (!fs.existsSync(DB_PATH)) {
createFile(DB_PATH);
}
var exportedData = db.export();
fs.writeFileSync(DB_PATH, exportedData);
// Finally, close the database connection and release the resources in memory.
db.close();
}
+67
View File
@@ -0,0 +1,67 @@
// Type definitions for sql.js
// Project: https://github.com/kripken/sql.js
// Definitions by: George Wu <https://github.com/Hozuki/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "sql.js" {
class Database {
constructor(data: Buffer);
constructor(data: Uint8Array);
constructor(data: number[]);
run(sql: string): Database;
run(sql: string, params: { [key: string]: number | string | Uint8Array }): Database;
run(sql: string, params: (number | string | Uint8Array)[]): Database;
exec(sql: string): QueryResults[];
each(sql: string, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void;
each(sql: string, params: { [key: string]: number | string | Uint8Array }, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void;
each(sql: string, params: (number | string | Uint8Array)[], callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void;
prepare(sql: string): Statement;
prepare(sql: string, params: { [key: string]: number | string | Uint8Array }): Statement;
prepare(sql: string, params: (number | string | Uint8Array)[]): Statement;
export(): Uint8Array;
close(): void;
}
class Statement {
bind(): boolean;
bind(values: { [key: string]: number | string | Uint8Array }): boolean;
bind(values: (number | string | Uint8Array)[]): boolean;
step(): boolean;
get(): (number | string | Uint8Array)[];
get(params: { [key: string]: number | string | Uint8Array }): (number | string | Uint8Array)[];
get(params: (number | string | Uint8Array)[]): (number | string | Uint8Array)[];
getColumnNames(): string[];
getAsObject(): { [columnName: string]: number | string | Uint8Array };
getAsObject(params: { [key: string]: number | string | Uint8Array }): { [columnName: string]: number | string | Uint8Array };
getAsObject(params: (number | string | Uint8Array)[]): { [columnName: string]: number | string | Uint8Array };
run(): void;
run(values: { [key: string]: number | string | Uint8Array }): void;
run(values: (number | string | Uint8Array)[]): void;
reset(): void;
freemem(): void;
free(): boolean;
}
interface QueryResults {
columns: string[];
values: (number | string | Uint8Array)[][];
}
}
+76
View File
@@ -0,0 +1,76 @@
// Author: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
/// <reference path="temp.d.ts" />
import * as temp from "temp";
function testCleanup() {
temp.cleanup(result => {
if (typeof result === "boolean") {
const x = result === true;
}
else {
const { files, dirs } = result;
files.toPrecision(4);
files.toPrecision(4);
}
});
}
function testCleanupSync() {
const cleanupResult = temp.cleanupSync()
if (typeof cleanupResult === "boolean") {
const x = cleanupResult === true;
}
else {
const { dirs, files } = cleanupResult
dirs.toPrecision(4);
files.toPrecision(4);
}
}
function testOpen() {
temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }, (err, result) => {
const { path, fd } = result;
path.length;
fd.toPrecision(5);
});
temp.open("strPrefix", (err, result) => {
const { path, fd } = result;
path.length;
fd.toPrecision(5);
});
}
function testOpenSync() {
const { fd: openFd1, path: openPath1 } = temp.openSync({ dir: "tempDir", prefix: "pref", suffix: "suff" });
const { fd: openFd2, path: openPath2 } = temp.openSync("str");
}
function testCreateWriteStream() {
const stream = temp.createWriteStream("HelloStreamAffix");
stream.write("data");
}
function testMkdir() {
temp.mkdir("prefix", (err, dirPath) => {
dirPath.length;
});
}
function testMkdirSync() {
const result = temp.mkdirSync("prefix");
result.length;
}
function testPath() {
const p = temp.path({ suffix: "justSuffix" }, "defaultPrefix");
p.length;
}
function testTrack() {
const tempChained = temp.track().track(true).track(false);
tempChained.dir;
tempChained.cleanupSync();
}
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for temp 0.8.3
// Project: https://www.npmjs.com/package/temp, https://github.com/bruce/node-temp
// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "temp" {
import * as temp from "temp";
import * as fs from "fs";
export interface AffixOptions {
prefix?: string;
suffix?: string;
dir?: string;
}
export var dir: string;
export function track(value?: boolean): typeof temp;
export function mkdir(affixes: string, callback?: (err: any, dirPath: string) => void): void;
export function mkdir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void;
export function mkdirSync(affixes: string): string;
export function mkdirSync(affixes: AffixOptions): string;
export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void): void;
export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void): void;
export function openSync(affixes: string): { path: string, fd: number };
export function openSync(affixes: AffixOptions): { path: string, fd: number };
export function path(affixes: string, defaultPrefix: string): string;
export function path(affixes: AffixOptions, defaultPrefix: string): string;
export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void): void;
export function cleanupSync(): boolean | {files: number, dirs: number};
export function createWriteStream(affixes: string): fs.WriteStream;
export function createWriteStream(affixes: AffixOptions): fs.WriteStream;
}
+2 -2
View File
@@ -1959,7 +1959,7 @@ declare module THREE {
constructor(manager?: LoadingManager);
manager: LoadingManager;
load(url: string, onLoad: (texture: CubeTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void;
load(urls: Array<string>, onLoad?: (texture: CubeTexture) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void;
setCrossOrigin(crossOrigin: string): void;
}
@@ -2076,7 +2076,7 @@ declare module THREE {
*
* @param url
*/
load(url: string, onLoad: (texture: Texture) => void): Texture;
load(url: string, onLoad?: (texture: Texture) => void): Texture;
setCrossOrigin(crossOrigin: string): void;
}
+224 -16
View File
@@ -1,33 +1,241 @@
/// <reference path="vue.d.ts" />
module myapp {
namespace TestConfig {
"use strict";
Vue.config.debug = true;
Vue.config.delimiters = ["${", "}"];
Vue.config.unsafeDelimiters = ['{!!', '!!}'];
Vue.config.silent = true;
Vue.config.async = false;
Vue.config.convertAllProperties = true;
}
namespace TestGlobalAPI {
"use strict";
var AppConstructor = Vue.extend({});
var extendedApp = new AppConstructor();
Vue.nextTick(() => {});
Vue.set({}, "key", "value");
Vue.delete({}, "key");
Vue.directive("directive", {
bind: function() {},
update: function(val: any, oldVal: any) {},
unbind: function() {},
params: ['a'],
paramWatchers: {
a: function(val: any, oldVal: any) {}
},
twoWay: true,
acceptStatement: true,
priority: 1,
count: 30
});
Vue.directive("my-directive", () => {});
var myDirective = Vue.directive("my-directive");
var elementDirective = Vue.elementDirective("element-directive");
Vue.elementDirective("element-directive", elementDirective);
Vue.elementDirective("element-directive", {
bind: function() {},
unbind: function() {}
});
var filter = Vue.filter("filter");
Vue.filter("filter", filter);
Vue.filter("filter", function(val: any) {
return val;
});
Vue.filter("filter", {
read: function(val: any) {},
write: function(val: any, oldVal: any) {}
});
var Component = Vue.component("component");
Vue.component("component", Component);
Vue.component("component", {
data: function() {
return { d: 0 }
},
methods: {
action: function() {}
},
props: ["a", "b"],
computed: {
a: function() { return this.d; },
b: {
get: function() { return this.a; },
set: function(val: number) { this.d = val; }
}
}
});
var transition = Vue.transition("transition");
Vue.transition("transition", transition);
Vue.transition("transition", {
css: false,
stagger: function(index) {
return index;
},
beforeEnter: function(el) {
el.textContent = 'beforeEnter';
},
enter: function(el, done) {
el.textContent = 'enter';
setTimeout(function() {
done();
}, 1000);
},
afterEnter: function(el) {
el.textContent = 'afterEnter';
},
enterCancelled: function(el) {
el.textContent = 'enterCancelled';
},
beforeLeave: function (el) {
el.textContent = 'beforeLeave';
},
leave: function (el, done) {
el.textContent = 'leave';
done();
},
afterLeave: function (el) {
el.textContent = 'afterLeave';
},
leaveCancelled: function (el) {
el.textContent = 'leaveCancelled';
}
});
var myPartial: string = Vue.partial("my-partial", "<div>Hello</div>");
myPartial = Vue.partial("my-partial");
Vue.use(() => {}, {});
Vue.use({install: () => {}, option: () => {}});
Vue.mixin({ready() {}});
}
namespace TestInstanceProperty {
"use strict";
var vm = new Vue({el: '#app'});
var data: any = vm.$data;
var el: HTMLElement = vm.$el;
var options: any = vm.$options;
var parent: any = vm.$parent;
var root: any = vm.$root;
var children: any[] = vm.$children;
var refs: any = vm.$refs;
var els: any = vm.$els;
}
namespace TestInscanceMethods {
"use strict";
var vm = new Vue({el: '#app'});
vm.$watch('a.b.c', function(newVal: string, oldVal: number) {});
vm.$watch(function() {return this.a + this.b}, function(newVal: string, oldVal: string) {});
var unwatch = vm.$watch('a', (value: any) => {});
unwatch();
vm.$watch('someObject', (value: any) => {}, {deep: true});
vm.$watch('a', (value: any) => {}, {immidiate: true});
vm.$get('a.b');
vm.$set('a.b', 2);
vm.$delete('a');
var s: string = vm.$eval('msg | uppercase');
s = vm.$interpolate('{{msg}} world!');
vm.$log();
vm.$log('item');
vm
.$on('test', (msg: any) => {})
.$once('testOnce', (msg: any) => {})
.$off("event", () => {})
.$emit("event", 1, 2)
.$dispatch("event", 1, 2, 3)
.$broadcast("event", 1, 2, 3, 4)
.$appendTo(document.createElement("div"), () => {})
.$before('#app', () => {})
.$after(document.getElementById('app'))
.$remove(() => {})
.$nextTick(() => {});
vm
.$mount('#app')
.$destroy(false);
}
namespace TestVueUtil {
"use strict";
var _ = Vue.util;
var target = document.createElement('div');
var child = document.createElement('div');
var parent = document.createElement('div');
var a: any[];
var b: boolean;
var f: Function;
var n: number;
var s: string;
var o: any;
o = _.checkComponentAttr(target, {});
_.warn('oops', new Error());
b = _.inDoc(target);
s = _.getAttr(target, 'v-test');
_.before(target, child);
_.after(target, child);
_.remove(target);
_.prepend(target, parent);
_.replace(child, target);
_.on(target, 'click', () => {});
_.off(target, 'click', () => {});
_.removeClass(target, 'header');
_.addClass(target, 'header');
_.nextTick(() => {}, {});
b = _.isLiteral('123');
s = _._toString('hi');
var ns: number | string = _.toNumber('12');
s = _.stripQuotes('"123"');
s = _.camelize('abc');
s = _.hyphenate('whatsUp');
s = _.classify('abc');
f = _.bind(() => {}, {});
a = _.toAarray(document.getElementsByClassName('target'));
o = _.extend({}, {a: 1, b: 2});
b = _.isObject({});
b = _.isPlainObject({});
b = _.isArray([]);
_.def({}, 'test', 123);
_.def({}, 'test2', 123, true);
f = _.debounce(() => {}, 100);
b = _.looseEqual(1, '1');
}
namespace TestExplicitExtend {
"use strict";
export class Application extends Vue {
text: string;
constructor() {
super();
Vue.config.debug = true;
this._init({
// data is necessary to always write in init()
data: {
text: "hello world."
// },
// methods : {
// action : this.action
/* same as unser */
},
methods: {
action: this.action
}
});
this.methods = {
action: this.action
};
}
action(): void {
console.log("action");
this.$on("event", (value: any) => {}).anotherAction();
}
anotherAction(): void {
this.$emit("event");
}
$els: {
target: HTMLDivElement;
}
}
var app = new Application();
app.$mount("#main").$destroy();
}
var app = new myapp.Application();
app.$mount("#main");
var AppConstructor = Vue.extend({});
var extendedApp = new AppConstructor();
app.$mount("#main");
+264 -165
View File
@@ -1,171 +1,270 @@
// Type definitions for vuejs 0.11.0
// Project: https://github.com/yyx990803/vue
// Definitions by: odangosan <https://github.com/odangosan>
// Type definitions for vuejs 1.0.11
// Project: https://github.com/vuejs/vue
// Definitions by: odangosan <https://github.com/odangosan>, kaorun343 <https://github.com/kaorun343>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module vuejs {
export class Vue {
/**
* The Vue Constructor
* http://vuejs.org/api/index.html
*/
constructor(options?: {});
/**
* Options
* http://vuejs.org/api/options.html
*/
/**
* Data
* http://vuejs.org/api/options.html#Data
*/
data: {};
methods: {};
computed: {};
paramAttributes:{}[];
/**
* DOM
* http://vuejs.org/api/options.html#DOM
*/
el: {};
template: string;
replace: boolean;
/**
* Lifecycle
* http://vuejs.org/api/options.html#Lifecycle
*/
created: VueCallback;
beforeCompile: VueCallback;
compiled: VueCallback;
ready: VueCallback;
attached: VueCallback;
detached: VueCallback;
beforeDestroy: VueCallback;
destroyed: VueCallback;
/**
* Assets
* http://vuejs.org/api/options.html#Assets
*/
directives: {};
filters: {};
components: {};
partials: {};
transitions: {};
/**
* Others
* http://vuejs.org/api/options.html#Others
*/
inherit: boolean;
events: {};
watch: {};
mixins:{}[];
name: string;
/**
* Instance Properties
* http://vuejs.org/api/instance-properties.html
*/
$el: HTMLElement;
$data: any;
$options: any;
$parent: Vue;
$root: Vue;
$: {};
$$: {};
/**
* Instance Methods
* http://vuejs.org/api/instance-methods.html
*/
/**
* Data
*/
$watch(expression: string, callback: ValueCallback, deep?: boolean, immediate?: boolean): void;
$get(expression: string): any;
$set(keypath: string, value: any): void;
$add(keypath: string, value: any): void;
$delete(keypath: string): void;
$eval(expression: string): any;
$interpolate(templateString: string): string;
$log(keypath?: string): void;
/**
* Events
*/
$dispatch(event: string, ...args: any[]): Vue;
$broadcast(event: string, ...args: any[]): Vue;
$emit(event: string, ...args: any[]): Vue;
$on(event: string, callback: Function): Vue;
$once(event: string, callback: Function): Vue;
$off(event?: string, callback?: Function): Vue;
/**
* DOM
*/
$appendTo(element: any, callback?: Function): Vue;// element or selector
$prependTo(element: any, callback?: Function): Vue;// element or selector
$before(element: any, callback?: Function): Vue;// element or selector
$after(element: any, callback?: Function): Vue;// element or selector
$remove(callback?: Function): Vue;
/**
* Lifecycle
*/
$mount(element?: any): Vue;// element or selector
$destroy(remove?: boolean): void;
$compile(element: HTMLElement): VueCallback;// returns a decompile function
$addChild(options?: {}, constructor?: Function): Vue;
/**
* Global Api
* http://vuejs.org/api/global-api.html
*/
static config: VueConfig;
static extend(options: {}): typeof Vue;
static directive(id: string, definition?: {}): void;
static directive(id: string, definition?: VueCallback): void;
static filter(id: string, definition?: FilterCallback): void;
static component(id: string, definition: Vue): void;
static component(id: string, definition?: {}): void;
static transition(id: string, definition?: {}): void;
static partial(id: string, definition?: string): void;
static partial(id: string, definition?: HTMLElement): void;
static nextTick(callback: VueCallback): void;
static require(module: string): void;
static use(plugin: {}, ...args: any[]): Vue;
static use(plugin: VueCallback, ...args: any[]): Vue;
/**
* exports members.
*/
_init(options: {}): void;
_cleanup(): void;
// static require(module:string) : void;
}
class VueConfig {
prefix: string;
debug: boolean;
silent: boolean;
proto: boolean;
interpolate: boolean;
async: boolean;
delimiters: string[];
}
interface ValueCallback {
(newValue: {}, oldValue: {}): void;
}
interface VueCallback {
(): void;
}
interface FilterCallback {
(value:{},begin?:{},end?:{}): {};
}
interface Array<T> {
$remove(item: T): Array<T>;
$set(index: number, val: T): T;
}
import Vue = vuejs.Vue;
declare namespace vuejs {
interface PropOption {
type?: any;
required?: boolean;
default?: boolean;
twoWay?: boolean;
validator?(value: any): boolean;
}
interface ComputedOption {
get(): any;
set(value: any): void;
}
interface WatchOption {
handler(val: any, oldVal: any): void;
deep?: boolean;
immidiate?: boolean;
}
interface DirectiveOption {
bind?(): any;
update?(newVal?: any, oldVal?: any): any;
unbind?(): any;
params?: string[];
deep?: boolean;
twoWay?: boolean;
acceptStatement?: boolean;
priority?: number;
[key: string]: any;
}
interface FilterOption {
read: Function;
write: Function;
}
interface TransitionOption {
css?: boolean;
beforeEnter?(el: HTMLElement): void;
enter?(el: HTMLElement, done?: () => void): void;
afterEnter?(el: HTMLElement): void;
enterCancelled?(el: HTMLElement): void;
beforeLeave?(el: HTMLElement): void;
leave?(el: HTMLElement, done?: () => void): void;
afterLeave?(el: HTMLElement): void;
leaveCancelled?(el: HTMLElement): void;
stagger?(index: number): number;
}
interface ComponentOption {
data?: {[key: string]: any } | Function;
props?: string[] | { [key: string]: PropOption };
computed?: { [key: string]: ( Function | ComputedOption ) };
methods?: { [key: string]: Function };
watch?: { [key: string]: ( (val: any, oldVal: any) => void | string | WatchOption )};
el?: string | HTMLElement | ( () => HTMLElement );
template?: string;
replace?: boolean;
created?(): void;
beforeCompile?(): void;
compiled?(): void;
ready?(): void;
attached?(): void;
detached?(): void;
beforeDestroy?(): void;
destroyed?(): void;
activate?(): void;
directives?: { [key: string]: ( DirectiveOption | Function ) };
elementDirectives?: { [key: string]: ( DirectiveOption | Function ) };
filters?: { [key: string]: ( Function | FilterOption ) };
components?: { [key: string]: ComponentOption };
transitions?: { [key: string]: TransitionOption };
partials?: { [key: string]: string };
parent?: Vue;
events?: { [key: string]: ( (...args: any[]) => ( boolean | void ) ) | string };
mixins?: ComponentOption[];
name?: string;
[key: string]: any;
}
// instance/api/data.js
interface $get { ( exp: string, asStatement?: boolean ): any; }
interface $set { <T>( key: string | number, value: T ): T; }
interface $delete { ( key: string) : void; }
interface $watch { ( expOrFn: string | Function, callback: ( (newVal: any, oldVal?: any) => any ) | string, options?: { deep?: boolean, immidiate?: boolean } ): Function; }
interface $eval { ( expression: string ): string; }
interface $interpolate { ( expression: string ): string; }
interface $log { ( keypath?: string ): void; }
// instance/api/dom.js
interface $nextTick { ( callback: Function ): void; }
interface $appendTo<V> { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; }
interface $prependTo<V> { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; }
interface $before<V> { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; }
interface $after<V> { ( target: ( HTMLElement | string ), callback?: Function, withTransition?: boolean ): V; }
interface $remove<V> { ( callback?: Function ): V; }
// instance/api/events.js
interface $on<V> { (event: string, callback: Function): V; }
interface $once<V> { (event: string, callback: Function): V; }
interface $off<V> { (event?: string, callback?: Function): V; }
interface $emit<V> { (event: string, ...args: any[]): V; }
interface $broadcast<V> { (event: string, ...args: any[]): V; }
interface $dispatch<V> { (event: string, ...args: any[]): V; }
// instance/api/lifecycle.js
interface $mount<V> { ( elementOrSelector?: ( HTMLElement | string ) ): V; }
interface $destroy { (remove?: boolean): void; }
interface $compile { (el: Element | DocumentFragment, host?: Vue): Function; }
interface Vue {
$data?: any;
$el?: HTMLElement;
$options?: Object;
$parent?: Vue;
$root?: Vue;
$children?: Vue[];
$refs?: Object;
$els?: Object;
$get?: $get;
$set?: $set;
$delete?: $delete;
$eval?: $eval;
$interpolate?: $interpolate;
$log?: $log;
$watch?: $watch;
$on?: $on<this>;
$once?: $once<this>;
$off?: $off<this>;
$emit?: $emit<this>;
$dispatch?: $dispatch<this>;
$broadcast?: $broadcast<this>;
$appendTo?: $appendTo<this>;
$before?: $before<this>;
$after?: $after<this>;
$remove?: $remove<this>;
$nextTick?: $nextTick;
$mount?: $mount<this>;
$destroy?: $destroy;
$compile?: $compile;
_init(options?: ComponentOption): void;
}
interface VueConfig {
debug: boolean;
delimiters: [string, string];
unsafeDelimiters: [string, string];
silent: boolean;
async: boolean;
convertAllProperties: boolean;
}
interface VueUtil {
// util/lang.js
set(obj: Object, key: string, value: any): void;
del(obj: Object, key: string): void;
hasOwn(obj: Object, key: string): boolean;
isLiteral(exp: string): boolean;
isReserved(str: string): boolean;
_toString(value: any): string;
toNumber<T>(value: T): T | number;
toBoolean<T>(value: T): T | boolean;
stripQuotes(str: string): string;
camelize(str: string): string;
hyphenate(str: string): string;
classify(str: string): string;
bind(fn: Function, ctx: Object): Function;
toAarray<T>(list: ArrayLike<T>, start?: number): Array<T>;
extend<T, F>(to: T, from: F): ( T & F );
isObject(obj: any): boolean;
isPlainObject(obj: any): boolean;
isArray: typeof Array.isArray;
def(obj: Object, key: string, value: any, enumerable?: boolean): void;
debounce(func: Function, wait: number): Function;
indexOf<T>(arr: Array<T>, obj: T): number;
cancellable(fn: Function): Function;
looseEqual(a: any, b: any): boolean;
// util/env.js
hasProto: boolean;
inBrowser: boolean;
isIE9: boolean;
isAndroid: boolean;
transitionProp: string;
transitionEndEvent: string;
animationProp: string;
animationEndEvent: string;
nextTick(cb: Function, ctx?: Object): void;
// util/dom.js
query(el: string | Element): Element;
inDoc(node: Node): boolean;
getAttr(node: Node, _attr: string): string;
getBindAttr(node: Node, name: string): string;
before(el: Element, target: Element): void;
after(el: Element, target: Element): void;
remove(el: Element): void;
prepend(el: Element, target: Element): void;
replace(target: Element, el: Element): void;
on(el: Element, event: string, cb: Function): void;
off(el: Element, event: string, cb: Function): void;
addClass(el: Element, cls: string): void;
removeClass(el: Element, cls: string): void;
extractContent(el: Element, asFragment: boolean): ( HTMLDivElement | DocumentFragment );
trimNode(node: Node): void;
isTemplate(el: Element): boolean;
createAnchor(content: string, persist: boolean): ( Comment | Text );
findRef(node: Element): string;
mapNodeRange(node: Node, end: Node, op: Function): void;
removeNodeRange(start: Node, end: Node, vm: any, frag: DocumentFragment, cb: Function): void;
// util/options.js
mergeOptions<P, C>(parent: P, child: C, vm?: any): ( P & C );
resolveAsset(options: Object, type: string, id: string): ( Object | Function );
assertAsset(val: any, type: string, id: string): void;
// util/component.js
commonTagRE: RegExp;
checkComponentAttr(el: Element, options?: Object): Object;
initProp(vm: Vue, prop: Object, value: any): void;
assertProp(prop: Object, value: any): boolean;
// util/debug.js
warn(msg: string, e?: Error): void;
// observer/index.js
defineReactive(obj: Object, key: string, val: any): void;
}
// instance/api/global.js
interface VueStatic {
new(options?: ComponentOption): Vue;
prototype: Vue;
util: VueUtil;
config: VueConfig;
set(object: Object, key: string, value: any): void;
delete(object: Object, key: string): void;
nextTick(callback: Function): any;
cid: number;
extend(options?: ComponentOption): VueStatic;
use(callback: Function | {install: Function, [key: string]: any}, option?: Object): VueStatic;
mixin(mixin: Object): void;
directive<T extends ( Function | DirectiveOption ) >(id: string, definition: T): T;
directive(id: string): any;
elementDirective<T extends ( Function | DirectiveOption ) >(id: string, definition: T): T;
elementDirective(id: string): any;
filter<T extends ( Function | FilterOption ) >(id: string, definition: T): T;
filter(id: string): any;
component(id: string, definition: ComponentOption): any;
component(id: string): any;
transition<T extends TransitionOption >(id: string, hooks: T): T;
transition(id: string): TransitionOption;
partial(id: string, partial: string): string;
partial(id: string): string;
}
}
declare var Vue: vuejs.VueStatic;
declare module "vue" {
import vue = vuejs.Vue;
export = vue;
export = Vue;
}
+411
View File
@@ -0,0 +1,411 @@
// adapted from `cat wu.js/test/* |sed '/= require/d'> wu-tests.ts`
///<reference path="wu.d.ts" />
declare var describe: any, it: any, mocha: any, assert: {
iterable:any;
eqSet<T>(expected:Set<T>, actual: Iterable<T>): any;
ok:any;
equal<T>(x:T, y:T): any;
eqArray<T>(x:T[], y:Iterable<T>): any;
deepEqual<T>(x:T, y:T): any;
}
// Helper for asserting that the given thing is iterable.
assert.iterable = thing => {
assert.ok(wu(thing));
};
// Helper for asserting that all the elements yielded from the |actual|
// iterator are in the |expected| set.
assert.eqSet = (expected, actual) => {
assert.iterable(actual);
for (var x of actual) {
assert.ok(expected.has(x));
expected.delete(x);
}
};
// Helper for asserting that all the elements yielded from the |actual|
// iterator are equal to and in the same order as the elements of the
// |expected| array.
assert.eqArray = (expected, actual) => {
assert.iterable(actual);
assert.deepEqual(expected, [...actual]);
};
mocha.setup('bdd');
describe("wu.asyncEach", () => {
it("should iterate over each item", () => {
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let n = 0;
return wu(arr)
.asyncEach(x => {
n++;
const start = Date.now();
while (Date.now() - start <= 3) {
// Kill time.
}
}, 3)
.then(() => {
assert.equal(n, arr.length);
});
});
});
describe("wu.chain", () => {
it("should concatenate iterables", () => {
assert.eqArray([1, 2, 3, 4, 5, 6],
wu.chain([1, 2], [3, 4], [5, 6]));
});
});
describe("wu.chunk", () => {
it("should chunk items into tuples", () => {
assert.eqArray([[1,2,3], [4,5,6]],
wu.chunk(3, [1,2,3,4,5,6]));
});
});
describe("wu.concatMap", () => {
it("should map the function over the iterable and concatenate results", () => {
assert.eqArray([1, 1, 2, 4, 3, 9],
wu.concatMap(x => [x, x * x], [1, 2, 3]));
});
});
describe("wu.count", () => {
it("should keep incrementing", () => {
const count = wu.count();
assert.equal(count.next().value, 0);
assert.equal(count.next().value, 1);
assert.equal(count.next().value, 2);
assert.equal(count.next().value, 3);
assert.equal(count.next().value, 4);
assert.equal(count.next().value, 5);
});
it("should start at the provided number", () => {
const count = wu.count(5);
assert.equal(count.next().value, 5);
assert.equal(count.next().value, 6);
assert.equal(count.next().value, 7);
});
it("should increment by the provided step", () => {
const count = wu.count(0, 2);
assert.equal(count.next().value, 0);
assert.equal(count.next().value, 2);
assert.equal(count.next().value, 4);
});
});
describe("wu.curryable", () => {
it("should wait until its given enough arguments", () => {
var f = wu.curryable((a, b) => a + b);
var f0 = f()()()()();
assert.equal(typeof f0, "function");
var f1 = f(1);
assert.equal(typeof f1, "function");
assert.equal(f1(2), 3);
});
it("should just call the function when given enough arguments", () => {
var f = wu.curryable((a, b) => a + b);
assert.equal(f(1, 2), 3);
});
it("should expect the number of arguments we tell it to", () => {
var f = wu.curryable((...args) => 5, 5);
assert.equal(typeof f(1, 2, 3, 4), "function");
assert.equal(f(1, 2, 3, 4, 5), 5);
});
});
describe("wu.cycle", () => {
it("should keep yielding items from the original iterable", () => {
let i = 0;
const arr = [1, 2, 3];
for (let x of wu.cycle(arr)) {
assert.equal(x, arr[i % 3]);
if (i++ > 9) {
break;
}
}
});
});
describe("wu.drop", () => {
it("should drop the number of items specified", () => {
const count = wu.count().drop(5);
assert.equal(count.next().value, 5);
});
});
describe("wu.dropWhile", () => {
it("should drop items while the predicate is true", () => {
const count = wu.dropWhile(x => x < 5, wu.count());
assert.equal(count.next().value, 5);
});
});
describe("wu.entries", () => {
it("should iterate over entries", () => {
const expected = new Map([["foo", 1], ["bar", 2], ["baz", 3]]);
for (let [k, v] of wu.entries({ foo: 1, bar: 2, baz: 3 })) {
assert.equal(expected.get(k), v);
}
});
});
describe("wu.enumerate", () => {
it("should yield items with their index", () => {
assert.eqArray([["a", 0], ["b", 1], ["c", 2]],
wu.enumerate("abc"));
});
});
describe("wu.every", () => {
it("should return true when the predicate succeeds for all items", () => {
assert.equal(true, wu.every(x => typeof x === "number", [1, 2, 3]));
});
it("should return false when the predicate fails for any item", () => {
assert.equal(false, wu.every(x => typeof x === "number", [1, 2, "3"]));
});
});
describe("wu.filter", () => {
it("should filter based on the predicate", () => {
assert.eqArray(["a", "b", "c"],
wu.filter(x => typeof x === "string",
[1, "a", true, "b", {}, "c"]));
});
});
describe("wu.find", () => {
it("should return the first item that matches the predicate", () => {
assert.deepEqual({ name: "rza" },
wu.find(x => !!x.name.match(/.za$/),
[{ name: "odb" },
{ name: "method man" },
{ name: "rza" },
{ name: "gza" }]));
});
it("should return undefined if no items match the predicate", () => {
assert.equal(undefined,
wu.find(x => (<any>x) === "raekwon",
[{ name: "odb" },
{ name: "method man" },
{ name: "rza" },
{ name: "gza" }]));
});
});
describe("wu.flatten", () => {
it("should flatten iterables", () => {
assert.eqArray(["I", "like", "LISP"],
wu(["I", ["like", ["LISP"]]]).flatten());
});
it("should shallowly flatten iterables", () => {
assert.eqArray([1, 2, 3, [[4]]],
wu.flatten(true, [1, [2], [3, [[4]]]]));
});
});
describe("wu.forEach", () => {
it("should iterate over every item", () => {
const items = [];
wu.forEach(x => items.push(x), [1,2,3]);
assert.eqArray([1,2,3], items);
});
});
describe("wu.has", () => {
it("should return true if the item is in the iterable", () => {
assert.ok(wu.has(3, [1,2,3]));
});
it("should return false if the item is not in the iterable", () => {
assert.ok(!wu.has(<any>"36 chambers", [1,2,3]));
});
});
describe("wu.invoke", () => {
it("should yield the method invokation on each item", () => {
function Greeter(name) {
this.name = name
}
Greeter.prototype.greet = function (tail) {
return "hello " + this.name + tail;
};
assert.eqArray(["hello world!", "hello test!"],
wu.invoke("greet", "!",
[new Greeter("world"), new Greeter("test")]));
});
});
describe("wu.keys", () => {
it("should iterate over keys", () => {
assert.eqSet(new Set(["foo", "bar", "baz"]),
wu.keys({ foo: 1, bar: 2, baz: 3 }));
});
});
describe("wu.map", () => {
it("should map the function over the iterable", () => {
assert.eqArray([1, 4, 9],
wu.map(x => x * x, [1, 2, 3]));
});
});
describe("wu.pluck", () => {
it("should access the named property of each item in the iterable", () => {
assert.eqArray([1, 2, 3],
wu.pluck("i", [{ i: 1 }, { i: 2 }, { i: 3 }]));
});
});
describe("wu.reduce", () => {
it("should reduce the iterable with the function", () => {
assert.equal(6, wu([1,2,3]).reduce((x, y) => x + y));
});
it("should accept an initial state for the reducer function", () => {
assert.equal(16, wu.reduce((x, y) => x + y, 10, [1,2,3]));
});
});
describe("wu.reductions", () => {
it("should yield the intermediate reductions of the iterable", () => {
assert.eqArray([1, 3, 6],
wu.reductions((x, y) => x + y, undefined, [1, 2, 3]));
});
});
describe("wu.reject", () => {
it("should yield items for which the predicate is false", () => {
assert.eqArray([1, true, {}],
wu.reject(x => typeof x === "string",
[1, "a", true, "b", {}, "c"]));
});
});
describe("wu.repeat", () => {
it("should keep yielding its item", () => {
const repeat = wu.repeat(3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
});
it("should repeat n times", () => {
const repeat = wu.repeat(3, 2);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, 3);
assert.equal(repeat.next().value, undefined);
assert.equal(repeat.next().done, true);
});
});
describe("wu.slice", () => {
it("should slice the front of iterables", () => {
assert.eqArray([3, 4, 5],
wu.slice(3, undefined, [0, 1, 2, 3, 4, 5]));
});
it("should slice the end of iterables", () => {
assert.eqArray([0, 1, 2],
wu.slice(undefined,
3,
[0, 1, 2, 3, 4, 5]));
});
});
describe("wu.some", () => {
it("should return true if any item matches the predicate", () => {
assert.ok(wu.some(x => x % 2 === 0, [1,2,3]));
});
it("should return false if no items match the predicate", () => {
assert.ok(!wu.some(x => x % 5 === 0, [1,2,3]));
});
});
describe("wu.spreadMap", () => {
it("should map the function over the iterable with spread arguments", () => {
assert.eqArray([32, 9, 1000],
wu.spreadMap(Math.pow, [[2, 5], [3, 2], [10, 3]]));
});
});
describe("wu.take", () => {
it("should yield as many items as requested", () => {
assert.eqArray([0, 1, 2, 3, 4],
wu.take(5, wu.count()));
});
});
describe("wu.takeWhile", () => {
it("should keep yielding items from the iterable until the predicate is false", () => {
assert.eqArray([0, 1, 2, 3, 4],
wu.takeWhile(x => x < 5, wu.count()));
});
});
describe("wu.tap", () => {
it("should perform side effects and yield the original item", () => {
let i = 0;
assert.eqArray([1, 2, 3],
wu.tap(x => i++, [1, 2, 3]));
assert.equal(i, 3);
});
});
describe("wu.tee", () => {
it("should clone iterables", () => {
const factorials = wu(wu.count(1)).reductions((a, b) => a * b);
const [i1, i2] = wu(factorials).tee();
assert.equal(i1.next().value, 1);
assert.equal(i1.next().value, 2);
assert.equal(i1.next().value, 6);
assert.equal(i1.next().value, 24);
assert.equal(i2.next().value, 1);
assert.equal(i2.next().value, 2);
assert.equal(i2.next().value, 6);
assert.equal(i2.next().value, 24);
});
});
describe("wu.unique", () => {
it("should yield only the unique items from the iterable", () => {
assert.eqArray([1, 2, 3],
wu.unique([1,1,2,2,1,1,3,3]));
});
});
describe("wu.unzip", () => {
it("should create iterables from zipped items", () => {
const pairs = [
["one", 1],
["two", 2],
["three", 3]
];
const [i1, i2] = wu(pairs).unzip();
assert.eqArray(["one", "two", "three"], [...i1]);
assert.eqArray([1, 2, 3], [...i2]);
});
});
describe("wu.values", () => {
it("should iterate over values", () => {
assert.eqSet(new Set([1, 2, 3]),
wu.values({ foo: 1, bar: 2, baz: 3 }));
});
});
describe("wu.zip", () => {
it("should zip two iterables together", () => {
assert.eqArray([["a", 1], ["b", 2], ["c", 3]],
wu.zip("abc", [1, 2, 3]));
});
it("should stop with the shorter iterable", () => {
assert.eqArray([["a", 1], ["b", 2], ["c", 3]],
wu.zip("abc", wu.count(1)));
});
});
describe("wu.zipLongest", () => {
it("should stop with the longer iterable", () => {
const arr1 = [];
arr1[1] = 2;
const arr2 = [];
arr2[1] = 3;
assert.eqArray([["a", 1], arr1, arr2],
wu.zipLongest("a", [1, 2, 3]));
});
});
describe("wu.zipWith", () => {
it("should spread map over the zipped iterables", () => {
const add3 = (a, b, c) => a + b + c;
assert.eqArray([12, 15, 18],
wu.zipWith(add3,
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]));
});
});
+1
View File
@@ -0,0 +1 @@
--target ES6
Vendored
+117
View File
@@ -0,0 +1,117 @@
// Type definitions for wu.js v2.1.0
// Project: https://fitzgen.github.io/wu.js/
// Definitions by: phiresky <https://github.com/phiresky/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Wu {
type Consumer<T> = (t: T) => void;
type Filter<T> = (t: T) => boolean;
export interface WuStatic {
<T>(iterable: Iterable<T>): WuIterable<T>;
// only static
chain<T>(...iters: Iterable<T>[]): WuIterable<T>;
count(start?: number, step?: number): WuIterable<number>;
curryable<T>(fun: (...x: any[]) => T, expected?: number): any;
entries<T>(obj: { [i: string]: T }): WuIterable<[string, T]>;
keys<T>(obj: { [i: string]: T }): WuIterable<string>;
values<T>(obj: { [i: string]: T }): WuIterable<T>;
repeat<T>(obj: T, times?: number): WuIterable<T>;
// also copied to WuInterface
asyncEach<T>(fn: Consumer<T>, maxBlock?: number, timeout?: number): void;
drop<T>(n: number, iter: Iterable<T>): WuIterable<T>;
dropWhile<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
cycle<T>(iter: Iterable<T>): Iterable<T>;
chunk<T>(n: number, iter: Iterable<T>): WuIterable<T[]>;
concatMap<T, U>(fn: (t: T) => Iterable<U>, iter: Iterable<T>): WuIterable<U>;
dropWhile<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
enumerate<T>(iter: Iterable<T>): Iterable<[number, T]>;
every<T>(fn: Filter<T>, iter: Iterable<T>): boolean;
filter<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
find<T>(fn: Filter<T>, iter: Iterable<T>): T;
flatten(iter: Iterable<any>): WuIterable<any>;
flatten(shallow: boolean, iter: Iterable<any>): WuIterable<any>;
forEach<T>(fn: Consumer<T>, iter: Iterable<T>): void;
has<T>(t: T, iter: Iterable<T>): boolean;
// invoke<T, U>(name:string, ...t:T[], iter: Iterable<(t:T)=>U>): WuIterable<U>;
invoke: any;
map<T, U>(fn: (t: T) => U, iter: Iterable<T>): WuIterable<U>;
// pluck<T>(attribute:string, iter: Iterable<{[attribute]: T}>): WuIterable<T>;
pluck(attribute: string, iter: Iterable<any>): WuIterable<any>;
reduce<T>(fn: (a: T, b: T) => T, iter: Iterable<T>): T;
reduce<T>(fn: (a: T, b: T) => T, initial: T, iter: Iterable<T>): T;
reduce<T, U>(fn: (a: U, b: T) => U, iter: Iterable<T>): U;
reduce<T, U>(fn: (a: U, b: T) => U, initial: U, iter: Iterable<T>): U;
reductions<T>(fn: (a: T, b: T) => T, iter: Iterable<T>): WuIterable<T>;
reductions<T>(fn: (a: T, b: T) => T, initial: T, iter: Iterable<T>): WuIterable<T>;
reductions<T, U>(fn: (a: U, b: T) => U, iter: Iterable<T>): WuIterable<U>;
reductions<T, U>(fn: (a: U, b: T) => U, initial: U, iter: Iterable<T>): WuIterable<U>;
reject<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
slice<T>(iter: Iterable<T>): WuIterable<T>;
slice<T>(start: number, iter: Iterable<T>): WuIterable<T>;
slice<T>(start: number, stop: number, iter: Iterable<T>): WuIterable<T>;
some<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
spreadMap<T>(fn: (...x: any[]) => T, iter: Iterable<any[]>): WuIterable<T>;
take<T>(n: number, iter: Iterable<T>): WuIterable<T>;
takeWhile<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
tap<T>(fn: Consumer<T>, iter: Iterable<T>): WuIterable<T>;
unique<T>(iter: Iterable<T>): WuIterable<T>;
zip<T, U>(iter2: Iterable<T>, iter: Iterable<U>): WuIterable<[T, U]>;
zipLongest<T, U>(iter2: Iterable<T>, iter: Iterable<U>): WuIterable<[T, U]>;
zipWith: any;
unzip: any;
tee<T>(iter: Iterable<T>): WuIterable<T>[];
tee<T>(n: number, iter: Iterable<T>): WuIterable<T>[];
}
export interface WuIterable<T> extends IterableIterator<T> {
// generated from section "copied to WuIterable" above via
// sed -r 's/(, )?iter: Iterable<\w+>//' |
// sed -r 's/^(\s+\w+)<T>/\1/' |
// sed -r 's/^(\s+\w+)<T, /\1</'
asyncEach<T>(fn: Consumer<T>, maxBlock?: number, timeout?: number): any;
drop(n: number): WuIterable<T>;
dropWhile(fn: Filter<T>): WuIterable<T>;
cycle(): Iterable<T>;
chunk(n: number): WuIterable<T[]>;
concatMap<U>(fn: (t: T) => Iterable<U>): WuIterable<U>;
dropWhile(fn: Filter<T>): WuIterable<T>;
enumerate(): Iterable<[number, T]>;
every(fn: Filter<T>): boolean;
filter(fn: Filter<T>): WuIterable<T>;
find(fn: Filter<T>): T;
flatten(): WuIterable<any>;
flatten(shallow: boolean): WuIterable<any>;
forEach(fn: Consumer<T>): void;
has(t: T): boolean;
// invoke<T, U>(name:string, ...t:T[], iter: Iterable<(t:T)=>U>): WuIterable<U>;
invoke: any;
map<U>(fn: (t: T) => U): WuIterable<U>;
// pluck<T>(attribute:string, iter: Iterable<{[attribute]: T}>): WuIterable<T>;
pluck(attribute: string): WuIterable<any>;
reduce(fn: (a: T, b: T) => T): T;
reduce(fn: (a: T, b: T) => T, initial: T): T;
reduce<U>(fn: (a: U, b: T) => U): U;
reduce<U>(fn: (a: U, b: T) => U, initial: U): U;
reductions(fn: (a: T, b: T) => T): WuIterable<T>;
reductions(fn: (a: T, b: T) => T, initial: T): WuIterable<T>;
reductions<U>(fn: (a: U, b: T) => U): WuIterable<U>;
reductions<U>(fn: (a: U, b: T) => U, initial: U): WuIterable<U>;
reject(fn: Filter<T>): WuIterable<T>;
slice(): WuIterable<T>;
slice(start: number): WuIterable<T>;
slice(start: number, stop: number): WuIterable<T>;
some(fn: Filter<T>): WuIterable<T>;
spreadMap(fn: (...x: any[]) => T, iter: Iterable<any[]>): WuIterable<T>;
take(n: number): WuIterable<T>;
takeWhile(fn: Filter<T>): WuIterable<T>;
tap(fn: Consumer<T>): WuIterable<T>;
unique(): WuIterable<T>;
zip<U>(iter2: Iterable<T>): WuIterable<[T, U]>;
zipLongest<U>(iter2: Iterable<T>): WuIterable<[T, U]>;
zipWith: any;
unzip: any;
tee(): WuIterable<T>[];
tee(n: number): WuIterable<T>[];
}
}
declare var wu: Wu.WuStatic;
+1
View File
@@ -0,0 +1 @@
--target ES6