Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'

This commit is contained in:
Daniel Furtado
2015-12-27 16:46:37 +01:00
143 changed files with 75992 additions and 1544 deletions
-1
View File
@@ -1 +0,0 @@
@@ -1 +0,0 @@
-1
View File
@@ -1 +0,0 @@
-1
View File
@@ -1 +0,0 @@
+5
View File
@@ -5,6 +5,11 @@
/// <reference path="../angularjs/angular.d.ts" />
declare module "angular-dynamic-locale" {
import ng = angular.dynamicLocale;
export = ng;
}
declare module angular.dynamicLocale {
interface tmhDynamicLocaleService {
+11
View File
@@ -70,6 +70,11 @@ declare module AngularFormly {
postWrapper?: ITemplateManipulator[];
}
interface ISelectOption {
name: string;
value?: string;
group?: string;
}
/**
* see http://docs.angular-formly.com/docs/ngmodelattrstemplatemanipulator
@@ -104,6 +109,12 @@ declare module AngularFormly {
description?: string;
[key: string]: any;
// types for select/radio fields
options?: Array<ISelectOption>;
groupProp?: string; // default: group
valueProp?: string; // default: value
labelProp?: string; // default: name
}
@@ -7,9 +7,17 @@ class TestController {
constructor($http: ng.IHttpService) {
$http.get("http://xyz.com", { ignoreLoadingBar: true })
}
}
app.controller('TestController', TestController);
var barConfig: angular.loadingBar.ILoadingBarProvider[] = [];
barConfig.push({
includeSpinner: true,
includeBar: true,
spinnerTemplate: 'template',
latencyThreshold: 100
});
+26 -1
View File
@@ -14,5 +14,30 @@ declare module angular {
*/
ignoreLoadingBar?: boolean;
}
}
}
declare module angular.loadingBar {
interface ILoadingBarProvider{
/**
* Turn the spinner on or off
*/
includeSpinner?: boolean;
/**
* Turn the loading bar on or off
*/
includeBar?: boolean;
/**
* HTML template
*/
spinnerTemplate?: string;
/**
* Latency Threshold
*/
latencyThreshold?: number;
}
}
@@ -196,6 +196,27 @@ function TestWebDriverUntilModule() {
conditionWebElements = protractor.until.elementsLocated(by.className('class'));
}
function TestWebDriverExpectedConditionsModule() {
var conditionB: protractor.until.Condition<boolean>;
var el: protractor.ElementFinder = element(by.id('id'));
conditionB = protractor.ExpectedConditions.alertIsPresent();
conditionB = protractor.ExpectedConditions.elementToBeClickable(el);
conditionB = protractor.ExpectedConditions.textToBePresentInElement(el, 'text');
conditionB = protractor.ExpectedConditions.textToBePresentInElementValue(el, 'text');
conditionB = protractor.ExpectedConditions.titleContains('text');
conditionB = protractor.ExpectedConditions.titleIs('text');
conditionB = protractor.ExpectedConditions.presenceOf(el);
conditionB = protractor.ExpectedConditions.stalenessOf(el);
conditionB = protractor.ExpectedConditions.visibilityOf(el);
conditionB = protractor.ExpectedConditions.invisibilityOf(el);
conditionB = protractor.ExpectedConditions.elementToBeSelected(el);
conditionB = protractor.ExpectedConditions.not(protractor.ExpectedConditions.alertIsPresent());
conditionB = protractor.ExpectedConditions.and(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el));
conditionB = protractor.ExpectedConditions.or(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el));
}
function TestProtractor() {
var ptor: protractor.Protractor;
var driver: webdriver.WebDriver = new webdriver.Builder().
+139
View File
@@ -501,6 +501,145 @@ declare module protractor {
function titleMatches(regex: RegExp): webdriver.until.Condition<boolean>;
}
module ExpectedConditions {
/**
* Negates the result of a promise.
*
* @param {webdriver.until.Condition<boolean>} expectedCondition
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns the negated value.
*/
function not<T>(expectedCondition: webdriver.until.Condition<T>): webdriver.until.Condition<T>;
/**
* Chain a number of expected conditions using logical_and, short circuiting at the
* first expected condition that evaluates to false.
*
* @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'and' together.
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which evaluates
* to the result of the logical and.
*/
function and<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;
/**
* Chain a number of expected conditions using logical_or, short circuiting at the
* first expected condition that evaluates to true.
*
* @param {...webdriver.until.Condition<boolean>[]} fns An array of expected conditions to 'or' together.
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise which
* evaluates to the result of the logical or.
*/
function or<T>(...fns: webdriver.until.Condition<T>[]): webdriver.until.Condition<T>;
/**
* Expect an alert to be present.
*
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether an alert is present.
*/
function alertIsPresent<T>(): webdriver.until.Condition<T>;
/**
* An Expectation for checking an element is visible and enabled such that you can click it.
*
* @param {ElementFinder} element The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the element is clickable.
*/
function elementToBeClickable<T>(element: ElementFinder): webdriver.until.Condition<T>;
/**
* An expectation for checking if the given text is present in the element.
* Returns false if the elementFinder does not find an element.
*
* @param {ElementFinder} element The element to check
* @param {string} text The text to verify against
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the text is present in the element.
*/
function textToBePresentInElement<T>(element: ElementFinder, text: string): webdriver.until.Condition<T>;
/**
* An expectation for checking if the given text is present in the elements value.
* Returns false if the elementFinder does not find an element.
*
* @param {ElementFinder} element The element to check
* @param {string} text The text to verify against
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the text is present in the element's value.
*/
function textToBePresentInElementValue<T>(
element: ElementFinder, text: string
): webdriver.until.Condition<T>;
/**
* An expectation for checking that the title contains a case-sensitive substring.
*
* @param {string} title The fragment of title expected
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the title contains the string.
*/
function titleContains<T>(title: string): webdriver.until.Condition<T>;
/**
* An expectation for checking the title of a page.
*
* @param {string} title The expected title, which must be an exact match.
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the title equals the string.
*/
function titleIs<T>(title: string): webdriver.until.Condition<T>;
/**
* An expectation for checking that an element is present on the DOM of a page. This does not necessarily
* mean that the element is visible. This is the opposite of 'stalenessOf'.
*
* @param {ElementFinder} elementFinder The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise
* representing whether the element is present.
*/
function presenceOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
/**
* An expectation for checking that an element is not attached to the DOM of a page.
* This is the opposite of 'presenceOf'.
*
* @param {ElementFinder} elementFinder The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the element is stale.
*/
function stalenessOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
/**
* An expectation for checking that an element is present on the DOM of a page and visible.
* Visibility means that the element is not only displayed but also has a height and width that is
* greater than 0. This is the opposite of 'invisibilityOf'.
*
* @param {ElementFinder} elementFinder The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the element is visible.
*/
function visibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
/**
* An expectation for checking that an element is present on the DOM of a page. This does not necessarily
* mean that the element is visible. This is the opposite of 'stalenessOf'.
*
* @param {ElementFinder} elementFinder The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the element is invisible.
*/
function invisibilityOf<T>(element: ElementFinder): webdriver.until.Condition<T>;
/**
* An expectation for checking the selection is selected.
*
* @param {ElementFinder} elementFinder The element to check
* @return {!webdriver.until.Condition<boolean>} An expected condition that returns a promise representing
* whether the element is selected.
*/
function elementToBeSelected<T>(element: ElementFinder): webdriver.until.Condition<T>;
}
//endregion
/**
+2 -2
View File
@@ -6,8 +6,8 @@
/// <reference path="../angularjs/angular.d.ts" />
declare module "angular-translate" {
var _: string;
export = _;
import ngt = angular.translate;
export = ngt;
}
declare module angular.translate {
+14 -2
View File
@@ -230,7 +230,7 @@ module UrlRouterProviderTests {
// this allows you to configure custom behavior in between
// location changes and route synchronization:
$urlRouterProvider.deferIntercept();
}).run(($rootScope: ng.IRootScopeService, $urlRouter: ng.ui.IUrlRouterService, UserService: ITestUserService) => {
}).run(($rootScope: ng.IRootScopeService, $urlRouter: ng.ui.IUrlRouterService, UserService: ITestUserService, $urlMatcher: ng.ui.IUrlMatcher) => {
$rootScope.$on('$locationChangeSuccess', e => {
// UserService is an example service for managing user state
if (UserService.isLoggedIn()) return;
@@ -245,6 +245,18 @@ module UrlRouterProviderTests {
});
// Configures $urlRouter's listener *after* your custom listener
$urlRouter.listen();
var listen: Function = $urlRouter.listen();
var href: string;
href = $urlRouter.href($urlMatcher);
href = $urlRouter.href($urlMatcher, {});
href = $urlRouter.href($urlMatcher, {}, {});
$urlRouter.update();
$urlRouter.update(false);
$urlRouter.push($urlMatcher);
$urlRouter.push($urlMatcher, {});
$urlRouter.push($urlMatcher, {}, {});
});
}
+4 -1
View File
@@ -300,7 +300,10 @@ declare module angular.ui {
*
*/
sync(): void;
listen(): void;
listen(): Function;
href(urlMatcher: IUrlMatcher, params?: IStateParamsService, options?: IHrefOptions): string;
update(read?: boolean): void;
push(urlMatcher: IUrlMatcher, params?: IStateParamsService, options?: IHrefOptions): void;
}
interface IUiViewScrollProvider {
+4
View File
@@ -5,6 +5,10 @@
/// <reference path="angular.d.ts" />
declare module 'angular-resource' {
var _: string;
export = _;
}
///////////////////////////////////////////////////////////////////////////////
// ngResource module (angular-resource.js)
+6
View File
@@ -128,6 +128,12 @@ declare module angular.route {
}
interface IRouteProvider extends IServiceProvider {
/**
* Match routes without being case sensitive
*
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
*/
caseInsensitiveMatch?: boolean;
/**
* Sets route definition that will be used on route change when no other route definition is matched.
*
+31 -1
View File
@@ -165,7 +165,7 @@ declare module angular {
dot: number;
codeName: string;
};
/**
* If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called.
* @param extraModules An optional array of modules that should be added to the original list of modules that the app was about to be bootstrapped with.
@@ -181,6 +181,13 @@ declare module angular {
animation(name: string, animationFactory: Function): IModule;
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
animation(object: Object): IModule;
/**
* Use this method to register a component.
*
* @param name The name of the component.
* @param options A definition object passed into the component.
*/
component(name: string, options: IComponentOptions): IModule;
/**
* Use this method to register work which needs to be performed on module loading.
*
@@ -1620,6 +1627,29 @@ declare module angular {
totalPendingRequests: number;
}
///////////////////////////////////////////////////////////////////////////
// Component
// see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html
// and http://toddmotto.com/exploring-the-angular-1-5-component-method/
///////////////////////////////////////////////////////////////////////////
interface IComponentOptions {
bindings?: Object;
controller?: string | Function;
controllerAs?: string;
isolate?: boolean;
template?: string | IComponentTemplateFn;
templateUrl?: string | IComponentTemplateFn;
transclude?: boolean;
restrict?: string;
$canActivate?: Function;
$routeConfig?: Object;
}
interface IComponentTemplateFn {
( $element?: IAugmentedJQuery, $attrs?: IAttributes ): string;
}
///////////////////////////////////////////////////////////////////////////
// Directive
// see http://docs.angularjs.org/api/ng.$compileProvider#directive
+4 -2
View File
@@ -1,7 +1,7 @@
/// <reference path="api-error-handler.d.ts" />
import errorHandler = require('api-error-handler');
import express = require('express');
import * as errorHandler from 'api-error-handler';
import * as express from 'express';
var api = express.Router();
api.get('/users/:userid', function (req, res, next) {
@@ -9,3 +9,5 @@ api.get('/users/:userid', function (req, res, next) {
});
api.use(errorHandler());
let res: errorHandler.Response;
+17 -1
View File
@@ -6,7 +6,23 @@
/// <reference path="../express/express.d.ts" />
declare module 'api-error-handler' {
import express = require('express');
import * as express from 'express';
namespace apiErrorHandler {
// Body response: the JSON returned by api-error-handler
// See https://github.com/expressjs/api-error-handler/blob/1.0.0/index.js
interface Response {
status: number;
stack?: string;
message: string;
// Client errors
code?: any;
name?: string;
type?: any;
}
}
function apiErrorHandler(options?: any): express.ErrorRequestHandler;
-1
View File
@@ -1 +0,0 @@
--noImplicitAny --module commonjs --target es5
@@ -0,0 +1,6 @@
/// <reference path="./backbone.localstorage.d.ts" />
var store: Store = new Store('testStore');
store.findAll();
store.save();
+51
View File
@@ -0,0 +1,51 @@
// Type definitions for backbone.localStorage 1.0.0
// Project: https://github.com/jeromegn/Backbone.localStorage
// Definitions by: Louis Grignon <https://github.com/lgrignon/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare module Backbone {
interface Serializer {
serialize(item: any): any;
deserialize(data: any): any;
}
class LocalStorage {
name: string;
serializer: Serializer;
records: string[];
constructor(name: string, serializer?: Serializer);
save(): void;
// Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
// have an id of it's own.
create(model: any): any;
// Update a model by replacing its copy in `this.data`.
update(model: any): any;
// Retrieve a model from `this.data` by id.
find(model: any): any;
// Return the array of all models currently in storage.
findAll(): any;
// Delete a model from `this.data`, returning it.
destroy<T>(model: T): T;
localStorage(): any;
// Clear localStorage for specific collection.
_clear(): void;
_storageSize(): number;
_itemName(id: any): string;
}
}
import Store = Backbone.LocalStorage;
+30
View File
@@ -0,0 +1,30 @@
/// <reference path="bcrypt-nodejs.d.ts" />
import bCrypt = require("bcrypt-nodejs");
function test_sync() {
var salt1 = bCrypt.genSaltSync();
var salt2 = bCrypt.genSaltSync(8);
var hash1 = bCrypt.hashSync('super secret');
var hash2 = bCrypt.hashSync('super secret', salt1);
var compare1 = bCrypt.compareSync('super secret', hash1);
var rounds1 = bCrypt.getRounds(hash2);
}
function test_async() {
var cbString = (error: Error, result: string) => {};
var cbVoid = () => {};
var cbBoolean = (error: Error, result: boolean) => {};
bCrypt.genSalt(8, cbString);
var salt = bCrypt.genSaltSync();
bCrypt.hash('super secret', salt, cbString);
bCrypt.hash('super secret', salt, cbVoid, cbString);
var hash = bCrypt.hashSync('super secret');
bCrypt.compare('super secret', hash, cbBoolean);
}
+68
View File
@@ -0,0 +1,68 @@
// Type definitions for bcrypt-nodejs
// Project: https://github.com/shaneGirish/bcrypt-nodejs
// Definitions by: David Broder-Rodgers <https://github.com/DavidBR-SW/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "bcrypt-nodejs" {
/**
* Generate a salt synchronously
* @param rounds Number of rounds to process the data for (default - 10)
* @return Generated salt
*/
export function genSaltSync(rounds?: number): string;
/**
* Generate a salt asynchronously
* @param rounds Number of rounds to process the data for (default - 10)
* @param callback Callback with error and resulting salt, to be fired once the salt has been generated
*/
export function genSalt(rounds: number, callback: (error: Error, result: string) => void): void;
/**
* Generate a hash synchronously
* @param data Data to be encrypted
* @param salt Salt to be used in encryption (default - new salt generated with 10 rounds)
* @return Generated hash
*/
export function hashSync(data: string, salt?: string): string;
/**
* Generate a hash asynchronously
* @param data Data to be encrypted
* @param salt Salt to be used in encryption
* @param callback Callback with error and hashed result, to be fired once the data has been encrypted
*/
export function hash(data: string, salt: string, callback: (error: Error, result: string) => void): void;
/**
* Generate a hash asynchronously
* @param data Data to be encrypted
* @param salt Salt to be used in encryption
* @param progressCallback Callback to be fired multiple times during the hash calculation to signify progress
* @param callback Callback with error and hashed result, to be fired once the data has been encrypted
*/
export function hash(data: string, salt: string, progressCallback: () => void, callback: (error: Error, result: string) => void): void;
/**
* Compares data with a hash synchronously
* @param data Data to be compared
* @param hash Hash to be compared to
* @return true if matching, false otherwise
*/
export function compareSync(data: string, hash: string): boolean;
/**
* Compares data with a hash asynchronously
* @param data Data to be compared
* @param hash Hash to be compared to
* @param callback Callback with error and match result, to be fired once the data has been compared
*/
export function compare(data: string, hash: string, callback: (error: Error, result: boolean) => void): void;
/**
* Get number of rounds used for hash
* @param hash Hash from which the number of rounds used should be extracted
* @return number of rounds used to encrypt a given hash
*/
export function getRounds(hash: string): number;
}
+111 -26
View File
@@ -85,15 +85,15 @@ var bazProm: Promise<Baz>;
// - - - - - - - - - - - - - - - - -
var numThen: Promise.Thenable<number>;
var strThen: Promise.Thenable<string>;
var anyThen: Promise.Thenable<any>;
var boolThen: Promise.Thenable<boolean>;
var objThen: Promise.Thenable<Object>;
var voidThen: Promise.Thenable<void>;
var numThen: PromiseLike<number>;
var strThen: PromiseLike<string>;
var anyThen: PromiseLike<any>;
var boolThen: PromiseLike<boolean>;
var objThen: PromiseLike<Object>;
var voidThen: PromiseLike<void>;
var fooThen: Promise.Thenable<Foo>;
var barThen: Promise.Thenable<Bar>;
var fooThen: PromiseLike<Foo>;
var barThen: PromiseLike<Bar>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -106,12 +106,12 @@ var barArrProm: Promise<Bar[]>;
// - - - - - - - - - - - - - - - - -
var numArrThen: Promise.Thenable<number[]>;
var strArrThen: Promise.Thenable<string[]>;
var anyArrThen: Promise.Thenable<any[]>;
var numArrThen: PromiseLike<number[]>;
var strArrThen: PromiseLike<string[]>;
var anyArrThen: PromiseLike<any[]>;
var fooArrThen: Promise.Thenable<Foo[]>;
var barArrThen: Promise.Thenable<Bar[]>;
var fooArrThen: PromiseLike<Foo[]>;
var barArrThen: PromiseLike<Bar[]>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -124,18 +124,18 @@ var barPromArr: Promise<Bar>[];
// - - - - - - - - - - - - - - - - -
var numThenArr: Promise.Thenable<number>[];
var strThenArr: Promise.Thenable<string>[];
var anyThenArr: Promise.Thenable<any>[];
var numThenArr: PromiseLike<number>[];
var strThenArr: PromiseLike<string>[];
var anyThenArr: PromiseLike<any>[];
var fooThenArr: Promise.Thenable<Foo>[];
var barThenArr: Promise.Thenable<Bar>[];
var fooThenArr: PromiseLike<Foo>[];
var barThenArr: PromiseLike<Bar>[];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// booya!
var fooThenArrThen: Promise.Thenable<Promise.Thenable<Foo>[]>;
var barThenArrThen: Promise.Thenable<Promise.Thenable<Bar>[]>;
var fooThenArrThen: PromiseLike<PromiseLike<Foo>[]>;
var barThenArrThen: PromiseLike<PromiseLike<Bar>[]>;
var fooResolver: Promise.Resolver<Foo>;
var barResolver: Promise.Resolver<Bar>;
@@ -607,19 +607,19 @@ Promise.all([fooProm, barProm, fooProm]).then(result => {
//TODO fix collection inference
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
barArrProm = fooArrProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
barArrProm = fooArrProm.map<Foo, Bar>((item: Foo) => {
return bar;
});
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
barArrProm = fooArrProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
return bar;
}, {
concurrency: 1
});
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
barArrProm = fooArrProm.map<Foo, Bar>((item: Foo) => {
return bar;
}, {
concurrency: 1
@@ -627,10 +627,20 @@ barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo, index: number, arrayLength: number) => {
barArrProm = fooArrProm.mapSeries<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = fooArrProm.mapSeries<Foo, Bar>((item: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooArrProm.reduce<Foo, Bar>((memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
});
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
barProm = fooArrProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
return memo;
}, bar);
@@ -1008,6 +1018,81 @@ barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number)
concurrency: 1
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// mapSeries()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArrThen
barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => {
return bar;
});
barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => {
return barThen;
});
barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArrThen
barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => {
return bar;
});
barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => {
return barThen;
});
barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArr
barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => {
return bar;
});
barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => {
return barThen;
});
barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArr
barArrProm = Promise.mapSeries(fooArr, (item: Foo) => {
return bar;
});
barArrProm = Promise.mapSeries(fooArr, (item: Foo) => {
return barThen;
});
barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reduce()
+724 -695
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -392,6 +392,7 @@ declare module breeze {
constructor(config?: EntityManagerOptions);
constructor(config?: string);
acceptChanges(): void;
addEntity(entity: Entity): Entity;
attachEntity(entity: Entity, entityState?: EntityStateSymbol, mergeStrategy?: MergeStrategySymbol): Entity;
clear(): void;
File diff suppressed because it is too large Load Diff
+388
View File
@@ -0,0 +1,388 @@
// Type definitions for chai 3.2.0
// Project: http://chaijs.com/
// Definitions by: Jed Mao <https://github.com/jedmao/>,
// Bart van der Schoor <https://github.com/Bartvds>,
// Andrew Brown <https://github.com/AGBrown>,
// Olivier Chevet <https://github.com/olivr70>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// <reference path="../assertion-error/assertion-error.d.ts"/>
declare module Chai {
interface ChaiStatic {
expect: ExpectStatic;
should(): Should;
/**
* Provides a way to extend the internals of Chai
*/
use(fn: (chai: any, utils: any) => void): any;
assert: AssertStatic;
config: Config;
AssertionError: typeof AssertionError;
}
export interface ExpectStatic extends AssertionStatic {
fail(actual?: any, expected?: any, message?: string, operator?: string): void;
}
export interface AssertStatic extends Assert {
}
export interface AssertionStatic {
(target: any, message?: string): Assertion;
}
interface ShouldAssertion {
equal(value1: any, value2: any, message?: string): void;
Throw: ShouldThrow;
throw: ShouldThrow;
exist(value: any, message?: string): void;
}
interface Should extends ShouldAssertion {
not: ShouldAssertion;
fail(actual: any, expected: any, message?: string, operator?: string): void;
}
interface ShouldThrow {
(actual: Function): void;
(actual: Function, expected: string|RegExp, message?: string): void;
(actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void;
}
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
not: Assertion;
deep: Deep;
any: KeyFilter;
all: KeyFilter;
a: TypeComparison;
an: TypeComparison;
include: Include;
includes: Include;
contain: Include;
contains: Include;
ok: Assertion;
true: Assertion;
false: Assertion;
null: Assertion;
undefined: Assertion;
NaN: Assertion;
exist: Assertion;
empty: Assertion;
arguments: Assertion;
Arguments: Assertion;
equal: Equal;
equals: Equal;
eq: Equal;
eql: Equal;
eqls: Equal;
property: Property;
ownProperty: OwnProperty;
haveOwnProperty: OwnProperty;
ownPropertyDescriptor: OwnPropertyDescriptor;
haveOwnPropertyDescriptor: OwnPropertyDescriptor;
length: Length;
lengthOf: Length;
match: Match;
matches: Match;
string(string: string, message?: string): Assertion;
keys: Keys;
key(string: string): Assertion;
throw: Throw;
throws: Throw;
Throw: Throw;
respondTo: RespondTo;
respondsTo: RespondTo;
itself: Assertion;
satisfy: Satisfy;
satisfies: Satisfy;
closeTo(expected: number, delta: number, message?: string): Assertion;
members: Members;
increase: PropertyChange;
increases: PropertyChange;
decrease: PropertyChange;
decreases: PropertyChange;
change: PropertyChange;
changes: PropertyChange;
extensible: Assertion;
sealed: Assertion;
frozen: Assertion;
}
interface LanguageChains {
to: Assertion;
be: Assertion;
been: Assertion;
is: Assertion;
that: Assertion;
which: Assertion;
and: Assertion;
has: Assertion;
have: Assertion;
with: Assertion;
at: Assertion;
of: Assertion;
same: Assertion;
}
interface NumericComparison {
above: NumberComparer;
gt: NumberComparer;
greaterThan: NumberComparer;
least: NumberComparer;
gte: NumberComparer;
below: NumberComparer;
lt: NumberComparer;
lessThan: NumberComparer;
most: NumberComparer;
lte: NumberComparer;
within(start: number, finish: number, message?: string): Assertion;
}
interface NumberComparer {
(value: number, message?: string): Assertion;
}
interface TypeComparison {
(type: string, message?: string): Assertion;
instanceof: InstanceOf;
instanceOf: InstanceOf;
}
interface InstanceOf {
(constructor: Object, message?: string): Assertion;
}
interface Deep {
equal: Equal;
include: Include;
property: Property;
members: Members;
}
interface KeyFilter {
keys: Keys;
}
interface Equal {
(value: any, message?: string): Assertion;
}
interface Property {
(name: string, value?: any, message?: string): Assertion;
}
interface OwnProperty {
(name: string, message?: string): Assertion;
}
interface OwnPropertyDescriptor {
(name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
(name: string, message?: string): Assertion;
}
interface Length extends LanguageChains, NumericComparison {
(length: number, message?: string): Assertion;
}
interface Include {
(value: Object, message?: string): Assertion;
(value: string, message?: string): Assertion;
(value: number, message?: string): Assertion;
keys: Keys;
members: Members;
any: KeyFilter;
all: KeyFilter;
}
interface Match {
(regexp: RegExp|string, message?: string): Assertion;
}
interface Keys {
(...keys: string[]): Assertion;
(keys: any[]): Assertion;
(keys: Object): Assertion;
}
interface Throw {
(): Assertion;
(expected: string, message?: string): Assertion;
(expected: RegExp, message?: string): Assertion;
(constructor: Error, expected?: string, message?: string): Assertion;
(constructor: Error, expected?: RegExp, message?: string): Assertion;
(constructor: Function, expected?: string, message?: string): Assertion;
(constructor: Function, expected?: RegExp, message?: string): Assertion;
}
interface RespondTo {
(method: string, message?: string): Assertion;
}
interface Satisfy {
(matcher: Function, message?: string): Assertion;
}
interface Members {
(set: any[], message?: string): Assertion;
}
interface PropertyChange {
(object: Object, prop: string, msg?: string): Assertion;
}
export interface Assert {
/**
* @param expression Expression to test for truthiness.
* @param message Message to display on error.
*/
(expression: any, message?: string): void;
fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
ok(val: any, msg?: string): void;
isOk(val: any, msg?: string): void;
notOk(val: any, msg?: string): void;
isNotOk(val: any, msg?: string): void;
equal(act: any, exp: any, msg?: string): void;
notEqual(act: any, exp: any, msg?: string): void;
strictEqual(act: any, exp: any, msg?: string): void;
notStrictEqual(act: any, exp: any, msg?: string): void;
deepEqual(act: any, exp: any, msg?: string): void;
notDeepEqual(act: any, exp: any, msg?: string): void;
isTrue(val: any, msg?: string): void;
isFalse(val: any, msg?: string): void;
isNull(val: any, msg?: string): void;
isNotNull(val: any, msg?: string): void;
isUndefined(val: any, msg?: string): void;
isDefined(val: any, msg?: string): void;
isNaN(val: any, msg?: string): void;
isNotNaN(val: any, msg?: string): void;
isAbove(val: number, abv: number, msg?: string): void;
isBelow(val: number, blw: number, msg?: string): void;
isFunction(val: any, msg?: string): void;
isNotFunction(val: any, msg?: string): void;
isObject(val: any, msg?: string): void;
isNotObject(val: any, msg?: string): void;
isArray(val: any, msg?: string): void;
isNotArray(val: any, msg?: string): void;
isString(val: any, msg?: string): void;
isNotString(val: any, msg?: string): void;
isNumber(val: any, msg?: string): void;
isNotNumber(val: any, msg?: string): void;
isBoolean(val: any, msg?: string): void;
isNotBoolean(val: any, msg?: string): void;
typeOf(val: any, type: string, msg?: string): void;
notTypeOf(val: any, type: string, msg?: string): void;
instanceOf(val: any, type: Function, msg?: string): void;
notInstanceOf(val: any, type: Function, msg?: string): void;
include(exp: string, inc: any, msg?: string): void;
include(exp: any[], inc: any, msg?: string): void;
notInclude(exp: string, inc: any, msg?: string): void;
notInclude(exp: any[], inc: any, msg?: string): void;
match(exp: any, re: RegExp, msg?: string): void;
notMatch(exp: any, re: RegExp, msg?: string): void;
property(obj: Object, prop: string, msg?: string): void;
notProperty(obj: Object, prop: string, msg?: string): void;
deepProperty(obj: Object, prop: string, msg?: string): void;
notDeepProperty(obj: Object, prop: string, msg?: string): void;
propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
lengthOf(exp: any, len: number, msg?: string): void;
//alias frenzy
throw(fn: Function, msg?: string): void;
throw(fn: Function, regExp: RegExp): void;
throw(fn: Function, errType: Function, msg?: string): void;
throw(fn: Function, errType: Function, regExp: RegExp): void;
throws(fn: Function, msg?: string): void;
throws(fn: Function, regExp: RegExp): void;
throws(fn: Function, errType: Function, msg?: string): void;
throws(fn: Function, errType: Function, regExp: RegExp): void;
Throw(fn: Function, msg?: string): void;
Throw(fn: Function, regExp: RegExp): void;
Throw(fn: Function, errType: Function, msg?: string): void;
Throw(fn: Function, errType: Function, regExp: RegExp): void;
doesNotThrow(fn: Function, msg?: string): void;
doesNotThrow(fn: Function, regExp: RegExp): void;
doesNotThrow(fn: Function, errType: Function, msg?: string): void;
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
operator(val: any, operator: string, val2: any, msg?: string): void;
closeTo(act: number, exp: number, delta: number, msg?: string): void;
sameMembers(set1: any[], set2: any[], msg?: string): void;
sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
includeMembers(superset: any[], subset: any[], msg?: string): void;
ifError(val: any, msg?: string): void;
isExtensible(obj: {}, msg?: string): void;
extensible(obj: {}, msg?: string): void;
isNotExtensible(obj: {}, msg?: string): void;
notExtensible(obj: {}, msg?: string): void;
isSealed(obj: {}, msg?: string): void;
sealed(obj: {}, msg?: string): void;
isNotSealed(obj: {}, msg?: string): void;
notSealed(obj: {}, msg?: string): void;
isFrozen(obj: Object, msg?: string): void;
frozen(obj: Object, msg?: string): void;
isNotFrozen(obj: Object, msg?: string): void;
notFrozen(obj: Object, msg?: string): void;
}
export interface Config {
includeStack: boolean;
}
export class AssertionError {
constructor(message: string, _props?: any, ssf?: Function);
name: string;
message: string;
showDiff: boolean;
stack: string;
}
}
declare var chai: Chai.ChaiStatic;
declare module "chai" {
export = chai;
}
interface Object {
should: Chai.Assertion;
}
+98
View File
@@ -1166,6 +1166,25 @@ function closeTo() {
}, 'blah: expected -10 to be close to 20 +/- 29');
}
function approximately() {
expect(1.5).to.be.approximately(1.0, 0.5);
(1.5).should.be.approximately(1.0, 0.5);
expect(10).to.be.approximately(20, 20);
(10).should.be.approximately(20, 20);
expect(-10).to.be.approximately(20, 30);
(-10).should.be.approximately(20, 30);
err(() => {
expect(2).to.be.approximately(1.0, 0.5, 'blah');
(2).should.be.approximately(1.0, 0.5, 'blah');
}, 'blah: expected 2 to be close to 1 +/- 0.5');
err(() => {
expect(-10).to.be.approximately(20, 29, 'blah');
(-10).should.be.approximately(20, 29, 'blah');
}, 'blah: expected -10 to be close to 20 +/- 29');
}
function includeMembers() {
expect([1, 2, 3]).to.include.members([]);
[1, 2, 3].should.include.members([]);
@@ -1255,6 +1274,20 @@ function increaseDecreaseChange() {
same.should.not.change(obj, "val");
}
function oneOf() {
var obj = { z: 3 };
expect(5).to.be.oneOf([1, 5, 4]);
expect('z').to.be.oneOf(['x', 'y', 'z']);
expect(obj).to.be.oneOf([obj]);
expect(5).to.not.be.oneOf([1, -12, 4]);
expect(5).to.not.be.oneOf([1, [5], 4]);
expect('z').to.not.be.oneOf(['w', 'x', 'y']);
expect('z').to.not.be.oneOf(['x', 'y', ['z']]);
expect(obj).to.not.be.oneOf([{ z: 3 }]);
}
//tdd
declare function suite(description: string, action: Function): void;
declare function test(description: string, action: Function): void;
@@ -1879,6 +1912,20 @@ suite('assert', () => {
}, 'expected -10 to be close to 20 +/- 29');
});
test('approximately', () => {
assert.approximately(1.5, 1.0, 0.5);
assert.approximately(10, 20, 20);
assert.approximately(-10, 20, 30);
err(() => {
assert.approximately(2, 1.0, 0.5);
}, 'expected 2 to be close to 1 +/- 0.5');
err(() => {
assert.approximately(-10, 20, 29);
}, 'expected -10 to be close to 20 +/- 29');
});
test('members', () => {
assert.includeMembers([1, 2, 3], [2, 3]);
assert.includeMembers([1, 2, 3], []);
@@ -1945,4 +1992,55 @@ suite('assert', () => {
test('notFrozen', () => { assert.notFrozen({}); });
test('isNotFrozen', () => { assert.isNotFrozen({}); });
test('isNotTrue', () => {
assert.isNotTrue(false);
err(() => {
assert.isNotTrue(true);
}, 'expected true to not be true');
});
test('isNotFalse', () => {
assert.isNotFalse(true);
err(() => {
assert.isNotFalse(false);
}, 'expected false to not be false');
});
test('isAtLeast', () => {
assert.isAtLeast(5, 3);
assert.isAtLeast(5, 5);
err(() => {
assert.isAtLeast(3, 5);
}, 'expected 3 to be greater than or equal to 5');
});
test('isAtMost', () => {
assert.isAtMost(3, 5);
assert.isAtMost(5, 5);
err(() => {
assert.isAtMost(5, 3);
}, 'expected 5 to be less than or equal to 3');
});
test('oneOf', () => {
var obj = { z: 3 };
assert.oneOf(5, [1, 5, 4]);
assert.oneOf('z', ['x', 'y', 'z']);
assert.oneOf(obj, [obj]);
err(() => {
assert.oneOf(5, [1, [5], 4]);
}, 'expected 5 to be one of [1, [5], 4]');
err(() => {
assert.oneOf('z', ['w', 'x', 'y']);
}, 'expected "z" to be one of [w, x, y]');
err(() => {
assert.oneOf(obj, [{ z: 3 }]);
}, 'expected { z: 3 } to be one of [{ z: 3 }]');
});
});
+18 -5
View File
@@ -1,9 +1,10 @@
// Type definitions for chai 3.2.0
// Type definitions for chai 3.4.0
// Project: http://chaijs.com/
// Definitions by: Jed Mao <https://github.com/jedmao/>,
// Bart van der Schoor <https://github.com/Bartvds>,
// Andrew Brown <https://github.com/AGBrown>,
// Olivier Chevet <https://github.com/olivr70>
// Olivier Chevet <https://github.com/olivr70>,
// Matt Wistrand <https://github.com/mwistrand>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// <reference path="../assertion-error/assertion-error.d.ts"/>
@@ -97,7 +98,8 @@ declare module Chai {
itself: Assertion;
satisfy: Satisfy;
satisfies: Satisfy;
closeTo(expected: number, delta: number, message?: string): Assertion;
closeTo: CloseTo;
approximately: CloseTo;
members: Members;
increase: PropertyChange;
increases: PropertyChange;
@@ -108,7 +110,7 @@ declare module Chai {
extensible: Assertion;
sealed: Assertion;
frozen: Assertion;
oneOf(list: any[], message?: string): Assertion;
}
interface LanguageChains {
@@ -155,6 +157,10 @@ declare module Chai {
(constructor: Object, message?: string): Assertion;
}
interface CloseTo {
(expected: number, delta: number, message?: string): Assertion;
}
interface Deep {
equal: Equal;
include: Include;
@@ -259,6 +265,9 @@ declare module Chai {
isTrue(val: any, msg?: string): void;
isFalse(val: any, msg?: string): void;
isNotTrue(val: any, msg?: string): void;
isNotFalse(val: any, msg?: string): void;
isNull(val: any, msg?: string): void;
isNotNull(val: any, msg?: string): void;
@@ -271,6 +280,9 @@ declare module Chai {
isAbove(val: number, abv: number, msg?: string): void;
isBelow(val: number, blw: number, msg?: string): void;
isAtLeast(val: number, atlst: number, msg?: string): void;
isAtMost(val: number, atmst: number, msg?: string): void;
isFunction(val: any, msg?: string): void;
isNotFunction(val: any, msg?: string): void;
@@ -339,6 +351,7 @@ declare module Chai {
operator(val: any, operator: string, val2: any, msg?: string): void;
closeTo(act: number, exp: number, delta: number, msg?: string): void;
approximately(act: number, exp: number, delta: number, msg?: string): void;
sameMembers(set1: any[], set2: any[], msg?: string): void;
sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
@@ -361,7 +374,7 @@ declare module Chai {
isNotFrozen(obj: Object, msg?: string): void;
notFrozen(obj: Object, msg?: string): void;
oneOf(inList: any, list: any[], msg?: string): void;
}
export interface Config {
+7 -7
View File
@@ -7578,31 +7578,31 @@ declare module chrome.webNavigation {
}
interface WebNavigationEvent extends chrome.events.Event {
addListener(callback: (details: WebNavigationCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationFramedEvent extends WebNavigationEvent {
addListener(callback: (details: WebNavigationFramedCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationFramedCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationFramedErrorEvent extends WebNavigationFramedEvent {
addListener(callback: (details: WebNavigationFramedErrorCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationFramedErrorCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationSourceEvent extends WebNavigationEvent {
addListener(callback: (details: WebNavigationSourceCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationSourceCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationParentedEvent extends WebNavigationEvent {
addListener(callback: (details: WebNavigationParentedCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationParentedCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationTransitionalEvent extends WebNavigationEvent {
addListener(callback: (details: WebNavigationTransitionCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationTransitionCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationReplacementEvent extends WebNavigationEvent {
addListener(callback: (details: WebNavigationReplacementCallbackDetails, filters?: WebNavigationEventFilter) => void): void;
addListener(callback: (details: WebNavigationReplacementCallbackDetails) => void, filters?: WebNavigationEventFilter): void;
}
/**
@@ -0,0 +1,73 @@
///<reference path="cordova-plugin-mapsforge.d.ts"/>
mapsforge.embedded.initialize(["/mnt/sdcard/spain.map",0,0]); //Creates the view
mapsforge.embedded.setCenter(43.360056,-5.845757); //Sets the center of the view
mapsforge.embedded.setMaxZoom(18);
mapsforge.embedded.setZoom(15);
//Adding a marker
var markerKey: number;
mapsforge.embedded.addMarker([mapsforge.embedded.MARKER_YELLOW,43.360056,-5.845757],function(key){markerKey = key;});
//Adding a polyline
var points = [43.360056,-5.845757, 43.160056,-5.645757,43.560056,-5.895757];
var polylineKey: number;
mapsforge.embedded.addPolyline([mapsforge.embedded.COLOR_GREEN,10,points], function(key){polylineKey = key;}, function(error){alert(error);});
mapsforge.cache.initialize("/mnt/sdcard/spain.map"); //Initializes the renderer with the offline map
/*Now you can use the Leaflet code seen before*/
mapsforge.cache.setExternalCache(false); //Sets the cache to internal for faster performance
//Now we set the cache size to 50 MB. This will increase the time between cleanings, but
//it will also make those cleanings slower, since there are a lot more of images to
//delete...so be careful when you choose the cache size
mapsforge.cache.setMaxCacheSize(50);
var L: any;
interface TilePoint {
x: number;
y: number;
z: number;
}
interface Tile {
src: string;
_layer: any;
onload: any;
onerror: any;
}
L.OfflineTileLayer = L.TileLayer.extend({
getTileUrl : function(tilePoint: TilePoint, tile: Tile) {
var zoom = tilePoint.z, x = tilePoint.x, y = tilePoint.y;
if (mapsforge.cache) {
mapsforge.cache.getTile([x,y,zoom], function(result) {tile.src=result;},
function() {tile.src = "path to an error image";});
}else{
tile.src = "path to an error image";
}
},
_loadTile: function (tile: Tile, tilePoint: TilePoint) {
tile._layer = this;
tile.onload = this._tileOnLoad;
tile.onerror = this._tileOnError;
this._adjustTilePoint(tilePoint);
this.getTileUrl(tilePoint, tile);
this.fire('tileloadstart', {
tile: tile,
url: tile.src
});
}
});
+249
View File
@@ -0,0 +1,249 @@
// Type definitions for cordova-plugin-mapsforge
// Project: https://github.com/afsuarez/mapsforge-cordova-plugin
// Definitions by: rafw87 <https://github.com/rafw87/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Window {
mapsforge: MapsforgePlugin;
}
declare var mapsforge: MapsforgePlugin;
interface MapsforgePlugin {
embedded: MapsforgeEmbeddedPlugin;
cache: MapsforgeCachePlugin;
}
interface MapsforgeEmbeddedPlugin {
COLOR_DKGRAY: number|string;
COLOR_CYAN: number|string;
COLOR_BLACK: number|string;
COLOR_BLUE: number|string;
COLOR_GREEN: number|string;
COLOR_RED: number|string;
COLOR_WHITE: number|string;
COLOR_TRANSPARENT: number|string;
COLOR_YELLOW: number|string;
MARKER_RED: number|string;
MARKER_GREEN: number|string;
MARKER_BLUE: number|string;
MARKER_YELLOW: number|string;
MARKER_BLACK: number|string;
MARKER_WHITE: number|string;
/**
* The map file path provided must be the absolute file path. You can specify the width and height values for the view that will be added,
* or you can set them to 0 for set the value to MATCH_PARENT. You must call this method before any other method.
* @param args Array in the following form: [String mapFilePath, int viewWidth, int viewHeight].
* @param success Success callback.
* @param error Error callback
*/
initialize(args: any[], success?: () => void, error?: (message: string) => void): void;
/**
* To show the map view.
* @param success Success callback.
* @param error Error callback
*/
show(success?: () => void, error?: (message: string) => void): void;
/**
* To hide the map view.
* @param success Success callback.
* @param error Error callback
*/
hide(success?: () => void, error?: (message: string) => void): void;
/**
* Sets the center of the map to the given coordinates.
* @param lat Latitude of the new center.
* @param lng Longitude of the new center.
* @param success Success callback.
* @param error Error callback
*/
setCenter(lat: number, lng: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the zoom to the specified value (if it is between the zoom limits).
* @param zoomLevel New zoom level.
* @param success Success callback.
* @param error Error callback
*/
setZoom(zoomLevel: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the maximum zoom level.
* @param maxZoom New maximum zoom level.
* @param success Success callback.
* @param error Error callback
*/
setMaxZoom(maxZoom: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the minimum zoom level.
* @param minZoom New minimum zoom level.
* @param success Success callback.
* @param error Error callback
*/
setMinZoom(minZoom: number, success?: () => void, error?: (message: string) => void): void;
/**
* The path to the map ile is required, and the path to the render theme may be null in order to apply the default render theme.
* @param args Array in the following form: [String mapFilePath, String renderThemePath]
* @param success Success callback.
* @param error Error callback
*/
setOfflineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void;
/**
*
* @param args Array in the following form: [String providerName, String host, String baseUrl, String extension, int port]
* @param success Success callback.
* @param error Error callback
*/
setOnlineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void;
/**
* Adds a marker to the map in the specified coordinates and returns the key for that marker to the success function.
* @param arg Array in the following form: [String marker_color, double lat, double lng].
* The color of the marker should be one of the constants from mapsforge.embedded object; if the marker doesn't exist a green marker will be used instead.
* @param success Success callback. Gets the key of created marker. That key is the one you have to use if you want to delete it.
* @param error Error callback
*/
addMarker(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void;
/**
*
* @param arg Array in the following form: [int color, int strokeWidth,[double points]].
* The color can be one of the constants specified before, or the new color you want.
* This function will use the odd positions of the array of points for the latitudes and the even positions for the longitudes.
* Example: [lat1, lng1, lat2, lng2, lat3, lng3].
* If the length of the array is not even, the function will throw an exception and return the error message to the error function.
* @param success Success callback. Gets the key of created polyline.
* @param error Error callback
*/
addPolyline(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void;
/**
* Deletes the layer(markers or polylines) with the specified key from the map.
* @param key Key of marker or polyline.
* @param success Success callback.
* @param error Error callback
*/
deleteLayer(key: number, success?: () => void, error?: (message: string) => void): void;
/**
* Initializes again the map if the onStop method was called.
* @param success Success callback.
* @param error Error callback
*/
onStart(success?: () => void, error?: (message: string) => void): void;
/**
* Stops the rendering. Useful for when the app goes to the background. You have to call the onStart method to restart it.
* @param success Success callback.
* @param error Error callback
*/
onStop(success?: () => void, error?: (message: string) => void): void;
/**
* Stops and cleans the resources that have been used.
* @param success Success callback.
* @param error Error callback
*/
onDestroy(success?: () => void, error?: (message: string) => void): void;
}
interface MapsforgeCachePlugin {
/**
* You should call this method before any other one, and provide it with the absolute map file path.
* @param mapFilePath Absolute map file path.
* @param success Success callback.
* @param error Error callback
*/
initialize(mapFilePath: string, success?: () => void, error?: (message: string) => void): void;
/**
* This method is the one that provides the tiles, generating them if their are not in the cache.
* @param args Array in the following form: [double lat, double lng, byte zoom]
* @param success Success callback. Gets the tile path.
* @param error Error callback
*/
getTile(args: any[], success?: (tilePath: string) => void, error?: (message: string) => void): void;
/**
* Enables or disables the cache. If disabled, the plugin will generate the tiles always from scratch. Cache is enabled by default.
* @param enabled Cache enabled or disabled.
* @param success Success callback.
* @param error Error callback
*/
setCacheEnabled(enabled: boolean, success?: () => void, error?: (message: string) => void): void;
/**
* Sets whether or not the cache should be placed in the internal memory or in the SD card.
* By default it is placed in SD card, so devices with not too much memory have a better performance.
* @param external Cache external or internal.
* @param success Success callback.
* @param error Error callback
*/
setExternalCache(external: boolean, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the map file to be used for rendering to the map specified by its absolute path.
* @param absolutePath Absolute map file path.
* @param success Success callback.
* @param error Error callback
*/
setMapFile(absolutePath: string, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the age for the generated images. This means that when the cache is being cleaned, all images younger than the specified value will be kept in the cache in order to avoid deleting images that are being used at the moment.
* @param milliseconds Max cache age in milliseconds.
* @param success Success callback.
* @param error Error callback
*/
setMaxCacheAge(milliseconds: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the maximum size for the cache. This size must be specified in megabytes. If there is not that space available, the cache will fit the maximum size.
* @param sizeInMB Max cache size in megabytes.
* @param success Success callback.
* @param error Error callback
*/
setMaxCacheSize(sizeInMB: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets the tile size. By default the tile size is set to 256.
* @param size Tile size.
* @param success Success callback.
* @param error Error callback
*/
setMaxCacheSize(size: number, success?: () => void, error?: (message: string) => void): void;
/**
* This method sets the size in megabytes that will remain always available in memory in order to avoid that the application uses all space available.
* @param sizeInMB Size in megabytes that will remain always available in memory.
* @param success Success callback.
* @param error Error callback
*/
setCacheCleaningTrigger(sizeInMB: number, success?: () => void, error?: (message: string) => void): void;
/**
* Sets a flag to destroy the cache when the onDestroy method is called.
* @param destroy If true, cache will be destroyed when the onDestroy method will be called.
* @param success Success callback.
* @param error Error callback
*/
destroyCacheOnExit(destroy: boolean, success?: () => void, error?: (message: string) => void): void;
/**
* Deletes the cache depending on the flag state.
* @param success Success callback.
* @param error Error callback
*/
onDestroy(success?: () => void, error?: (message: string) => void): void;
}
+10 -10
View File
@@ -45,16 +45,16 @@ interface Connection {
* Connection.CELL
* Connection.NONE
*/
type: number
type: string
}
declare var Connection: {
UNKNOWN: number;
ETHERNET: number;
WIFI: number;
CELL_2G: number;
CELL_3G: number;
CELL_4G: number;
CELL: number;
NONE: number;
}
UNKNOWN: string;
ETHERNET: string;
WIFI: string;
CELL_2G: string;
CELL_3G: string;
CELL_4G: string;
CELL: string;
NONE: string;
}
+149
View File
@@ -0,0 +1,149 @@
/// <reference path="create-error.d.ts" />
/// <reference path="../node/node.d.ts" />
/// <reference path="../mocha/mocha.d.ts" />
import * as createError from 'create-error';
import * as assert from 'assert';
// Example taken from https://github.com/tgriesser/create-error/blob/0.3.1/README.md#use
interface MyCustomError extends createError.Error<MyCustomError> {
messages: string[];
someVal: string;
}
var MyCustomError = createError<MyCustomError>('MyCustomError');
interface SubCustomError extends MyCustomError {
}
var SubCustomError = createError<SubCustomError>(MyCustomError, 'CoolSubError', {messages: []});
var sub = new SubCustomError('My Message', {someVal: 'value'});
sub instanceof SubCustomError // true
sub instanceof MyCustomError // true
sub instanceof Error // true
assert.deepEqual(sub.messages, []) // true
assert.equal(sub.someVal, 'value') // true
// Taken and adapted from https://github.com/tgriesser/create-error/blob/0.3.1/test/index.js
var equal = assert.equal;
var deepEqual = assert.deepEqual;
describe('create-error', function() {
describe('error creation', function() {
it('should create a new error', function() {
var TestingError = createError('TestingError');
var a = new TestingError('msgA');
var b = new TestingError('msgB');
equal((a instanceof TestingError), true);
equal((a instanceof Error), true);
equal(a.message, 'msgA');
equal(b.message, 'msgB');
equal((a.stack.length > 0), true);
});
it('should attach properties in the second argument', function() {
interface TestingError extends createError.Error<TestingError> {
anArray: string[];
}
var TestingError = createError<TestingError>('TestingError', {anArray: []});
var a = new TestingError('Test the array');
deepEqual(a.anArray, []);
});
it('should give the name "CustomError" if the name is omitted', function() {
var TestingError = createError();
var a = new TestingError("msg");
equal(a.name, 'CustomError');
});
it('should not reference the same property in subsequent errors', function() {
interface TestingError extends createError.Error<TestingError> {
anArray: string[];
}
var TestingError = createError<TestingError>('TestingError', {anArray: []});
var a = new TestingError('Test the array');
a.anArray.push('a');
var b = new TestingError('');
deepEqual(b.anArray, []);
});
it('should allow for empty objects on the cloned hash', function() {
interface TestingError extends createError.Error<TestingError> {
anEmptyObj: Object;
}
var TestingError = createError<TestingError>('TestingError', {anEmptyObj: Object.create(null)});
var a = new TestingError('Test the array');
deepEqual(a.anEmptyObj, Object.create(null));
});
it('attaches attrs in the second arg of the error ctor, #3', function() {
interface RequestError extends createError.Error<RequestError> {
status: number;
}
var RequestError = createError<RequestError>('RequestError', {status: 400});
var reqErr = new RequestError('404 Error', {status: 404});
equal(reqErr.status, 404);
equal(reqErr.message, '404 Error');
equal(reqErr.name, 'RequestError');
});
});
describe('subclassing errors', function() {
it('takes an object in the first argument', function() {
var TestingError = createError('TestingError');
var SubTestingError = createError(TestingError, 'SubTestingError');
var x = new SubTestingError();
equal((x instanceof SubTestingError), true);
equal((x instanceof TestingError), true);
equal((x instanceof Error), true);
});
it('attaches the properties appropriately.', function() {
interface SubTestingError extends createError.Error<SubTestingError> {
key: string[];
}
var TestingError = createError('TestingError');
var SubTestingError = createError<SubTestingError>(TestingError, 'SubTestingError', {key: []});
var x = new SubTestingError();
deepEqual(x.key, []);
});
it('allows for a default message, #4', function() {
var TestingError = createError('TestingError', {message: 'Error with testing'});
var x = new TestingError();
equal(x.message, 'Error with testing');
});
});
describe('invalid values sent to the second argument', function() {
it('should ignore falsy values', function() {
var TestingError = createError('TestingError', '');
var TestingError2 = createError('TestingError', null);
var TestingError3 = createError('TestingError', void 0);
var a = new TestingError('Test the array');
var b = new TestingError2('Test the array');
var c = new TestingError3('Test the array');
});
it('should ignore arrays', function() {
interface TestingError extends createError.Error<TestingError> {
anArray: string[];
}
var TestingError = createError<TestingError>('TestingError', [{anArray: []}]);
var a = new TestingError('Test the array');
equal(a.anArray, void 0);
});
});
});
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for create-error.js 0.3.1
// Project: https://github.com/tgriesser/create-error
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'create-error' {
// FIXME See Global type references https://github.com/Microsoft/TypeScript/issues/983
type Err = Error;
namespace createError {
interface Error<T extends Err> extends Err {
new (message?: string, obj?: any): T;
}
}
function createError(): createError.Error<Error>;
function createError<T extends createError.Error<Error>>(name: string, properties?: any): T;
function createError<T extends createError.Error<Error>>(Target: createError.Error<Error>, name?: string, properties?: any): T;
export = createError;
}
+2 -3
View File
@@ -1,4 +1,3 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="debug.d.ts" />
import debug = require("debug");
@@ -6,7 +5,7 @@ import debug = require("debug");
debug.disable();
debug.enable("DefinitelyTyped:*");
var log: debug.Debugger = debug("DefinitelyTyped:log");
var log:debug.IDebugger = debug("DefinitelyTyped:log");
log("Just text");
log("Formatted test (%d arg)", 1);
@@ -15,6 +14,6 @@ log("Formatted %s (%d args)", "test", 2);
log("Enabled?: %s", debug.enabled("DefinitelyTyped:log"));
log("Namespace: %s", log.namespace);
var error: debug.Debugger = debug("DefinitelyTyped:error");
var error:debug.IDebugger = debug("DefinitelyTyped:error");
error.log = console.error.bind(console);
error("This should be printed to stderr");
+31 -23
View File
@@ -1,30 +1,38 @@
// Type definitions for debug
// Project: https://github.com/visionmedia/debug
// Definitions by: Seon-Wook Park <https://github.com/swook>
// Definitions by: Seon-Wook Park <https://github.com/swook>, Gal Talmor <https://github.com/galtalmor>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "debug" {
function d(namespace: string): d.Debugger;
module d {
export var log: Function;
function enable(namespaces: string): void;
function disable(): void;
function enabled(namespace: string): boolean;
export interface Debugger {
(formatter: any, ...args: any[]): void;
enabled: boolean;
log: Function;
namespace: string;
}
}
export = d;
declare var debug: debug.IDebug;
// Support AMD require
declare module 'debug' {
export = debug;
}
declare module debug {
export interface IDebug {
(namespace: string): debug.IDebugger,
coerce: (val: any) => any,
disable: () => void,
enable: (namespaces: string) => void,
enabled: (namespaces: string) => boolean,
names: string[],
skips: string[],
formatters: IFormatters
}
export interface IFormatters {
[formatter: string]: Function
}
export interface IDebugger {
(formatter: any, ...args: any[]): void;
enabled: boolean;
log: Function;
namespace: string;
}
}
+3 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Drop v0.5.7
// Type definitions for Drop v1.3.0
// Project: http://github.hubspot.com/drop/
// Definitions by: Adi Dahiya <https://github.com/adidahiya>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -26,6 +26,7 @@ declare module drop {
constrainToWindow?: boolean;
constrainToScrollParent?: boolean;
remove?: boolean;
beforeClose?: () => boolean;
tetherOptions?: tether.ITetherOptions;
}
@@ -37,6 +38,7 @@ declare module drop {
close(): void;
remove(): void;
toggle(): void;
isOpened(): boolean;
position(): void;
destroy(): void;
/*
+2 -2
View File
@@ -4,6 +4,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "email-addresses" {
function parseOneAddress(opts: any): Object;
function parseAddressList(opts: any): Object;
function parseOneAddress(opts: any): any;
function parseAddressList(opts: any): any;
}
+574
View File
@@ -0,0 +1,574 @@
/// <reference path="enzyme.d.ts" />
/// <reference path="../react/react.d.ts"/>
import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme";
import * as React from "react";
import {Component, ReactElement} from "react";
import {ShallowWrapper, ReactWrapper, CheerioWrapper} from "enzyme";
// Help classes/interfaces
interface MyComponentProps {
propsProperty: any;
}
interface MyComponentState {
stateProperty: any;
}
class MyComponent extends Component<MyComponentProps, MyComponentState> {
setState(...args: any[]) {
}
}
// API
module SpyLifecycleTest {
spyLifecycle(MyComponent);
}
// ShallowWrapper
module ShallowWrapperTest {
var shallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState> =
shallow<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
var reactElement: ReactElement<any>,
objectVal: Object,
boolVal: Boolean,
stringVal: String;
function test_find() {
shallowWrapper = shallowWrapper.find('.selector');
shallowWrapper = shallowWrapper.find(MyComponent);
}
function test_findWhere() {
shallowWrapper =
shallowWrapper.findWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_filter() {
shallowWrapper = shallowWrapper.filter('.selector');
shallowWrapper = shallowWrapper.filter(MyComponent);
}
function test_filterWhere() {
shallowWrapper =
shallowWrapper.filterWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_contains() {
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
}
function test_hasClass() {
boolVal = shallowWrapper.find('.my-button').hasClass('disabled');
}
function test_is() {
boolVal = shallowWrapper.is('.some-class');
}
function test_not() {
shallowWrapper = shallowWrapper.find('.foo').not('.bar');
}
function test_children() {
shallowWrapper = shallowWrapper.children();
}
function test_parents() {
shallowWrapper = shallowWrapper.parents();
}
function test_parent() {
shallowWrapper = shallowWrapper.parent();
}
function test_closest() {
shallowWrapper = shallowWrapper.closest('.selector');
shallowWrapper = shallowWrapper.closest(MyComponent);
}
function test_shallow() {
shallowWrapper = shallowWrapper.shallow();
}
function test_render() {
var cheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState> = shallowWrapper.render();
}
function test_text() {
stringVal = shallowWrapper.text();
}
function test_html() {
stringVal = shallowWrapper.html();
}
function test_get() {
reactElement = shallowWrapper.get(1);
}
function test_at() {
shallowWrapper = shallowWrapper.at(1);
}
function test_first() {
shallowWrapper = shallowWrapper.first();
}
function test_last() {
shallowWrapper = shallowWrapper.last();
}
function test_state() {
shallowWrapper.state();
shallowWrapper.state('key');
}
function test_props() {
objectVal = shallowWrapper.props();
}
function test_prop() {
shallowWrapper.prop('key');
}
function test_simulate(...args: any[]) {
shallowWrapper.simulate('click');
shallowWrapper.simulate('click', args);
}
function test_setState() {
shallowWrapper = shallowWrapper.setState({stateProperty: 'state'});
}
function test_setProps() {
shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'});
}
function test_setContext() {
shallowWrapper = shallowWrapper.setContext({name: 'baz'});
}
function test_instance() {
var myComponent: MyComponent = shallowWrapper.instance();
}
function test_update() {
shallowWrapper = shallowWrapper.update();
}
function test_debug() {
stringVal = shallowWrapper.debug();
}
function test_type() {
var stringOrFunction: String|Function = shallowWrapper.type();
}
function test_forEach() {
shallowWrapper =
shallowWrapper.forEach((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_map() {
var arrayVal: Array<any> =
shallowWrapper.map((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_reduce() {
const total: number[] =
shallowWrapper.reduce<number>(
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_reduceRight() {
const total: number[] =
shallowWrapper.reduceRight<number>(
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_some() {
boolVal = shallowWrapper.some('.selector');
boolVal = shallowWrapper.some(MyComponent);
}
function test_someWhere() {
boolVal = shallowWrapper.someWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_every() {
boolVal = shallowWrapper.every('.selector');
boolVal = shallowWrapper.every(MyComponent);
}
function test_everyWhere() {
boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
}
}
// ReactWrapper
module ReactWrapperTest {
var reactWrapper: ReactWrapper<MyComponentProps, MyComponentState> =
mount<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
var reactElement: ReactElement<any>,
objectVal: Object,
boolVal: Boolean,
stringVal: String;
function test_find() {
reactWrapper = reactWrapper.find('.selector');
reactWrapper = reactWrapper.find(MyComponent);
}
function test_findWhere() {
reactWrapper =
reactWrapper.findWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_filter() {
reactWrapper = reactWrapper.filter('.selector');
reactWrapper = reactWrapper.filter(MyComponent);
}
function test_filterWhere() {
reactWrapper =
reactWrapper.filterWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_contains() {
boolVal = reactWrapper.contains(<div className="foo bar"/>);
}
function test_hasClass() {
boolVal = reactWrapper.find('.my-button').hasClass('disabled');
}
function test_is() {
boolVal = reactWrapper.is('.some-class');
}
function test_not() {
reactWrapper = reactWrapper.find('.foo').not('.bar');
}
function test_children() {
reactWrapper = reactWrapper.children();
}
function test_parents() {
reactWrapper = reactWrapper.parents();
}
function test_parent() {
reactWrapper = reactWrapper.parent();
}
function test_closest() {
reactWrapper = reactWrapper.closest('.selector');
reactWrapper = reactWrapper.closest(MyComponent);
}
function test_text() {
stringVal = reactWrapper.text();
}
function test_html() {
stringVal = reactWrapper.html();
}
function test_get() {
reactElement = reactWrapper.get(1);
}
function test_at() {
reactWrapper = reactWrapper.at(1);
}
function test_first() {
reactWrapper = reactWrapper.first();
}
function test_last() {
reactWrapper = reactWrapper.last();
}
function test_state() {
reactWrapper.state();
reactWrapper.state('key');
}
function test_props() {
objectVal = reactWrapper.props();
}
function test_prop() {
reactWrapper.prop('key');
}
function test_simulate(...args: any[]) {
reactWrapper.simulate('click');
reactWrapper.simulate('click', args);
}
function test_setState() {
reactWrapper = reactWrapper.setState({stateProperty: 'state'});
}
function test_setProps() {
reactWrapper = reactWrapper.setProps({propsProperty: 'foo'});
}
function test_setContext() {
reactWrapper = reactWrapper.setContext({name: 'baz'});
}
function test_instance() {
var myComponent: MyComponent = reactWrapper.instance();
}
function test_update() {
reactWrapper = reactWrapper.update();
}
function test_debug() {
stringVal = reactWrapper.debug();
}
function test_type() {
var stringOrFunction: String|Function = reactWrapper.type();
}
function test_forEach() {
reactWrapper =
reactWrapper.forEach((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_map() {
var arrayVal: Array<any> =
reactWrapper.map((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_reduce() {
const total: number[] =
reactWrapper.reduce<number>(
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_reduceRight() {
const total: number[] =
reactWrapper.reduceRight<number>(
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_some() {
boolVal = reactWrapper.some('.selector');
boolVal = reactWrapper.some(MyComponent);
}
function test_someWhere() {
boolVal = reactWrapper.someWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_every() {
boolVal = reactWrapper.every('.selector');
boolVal = reactWrapper.every(MyComponent);
}
function test_everyWhere() {
boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
}
}
// CheerioWrapper
module CheerioWrapperTest {
var cheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState> =
render<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
var reactElement: ReactElement<any>,
objectVal: Object,
boolVal: Boolean,
stringVal: String;
function test_find() {
cheerioWrapper = cheerioWrapper.find('.selector');
cheerioWrapper = cheerioWrapper.find(MyComponent);
}
function test_findWhere() {
cheerioWrapper =
cheerioWrapper.findWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_filter() {
cheerioWrapper = cheerioWrapper.filter('.selector');
cheerioWrapper = cheerioWrapper.filter(MyComponent);
}
function test_filterWhere() {
cheerioWrapper =
cheerioWrapper.filterWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_contains() {
boolVal = cheerioWrapper.contains(<div className="foo bar"/>);
}
function test_hasClass() {
boolVal = cheerioWrapper.find('.my-button').hasClass('disabled');
}
function test_is() {
boolVal = cheerioWrapper.is('.some-class');
}
function test_not() {
cheerioWrapper = cheerioWrapper.find('.foo').not('.bar');
}
function test_children() {
cheerioWrapper = cheerioWrapper.children();
}
function test_parents() {
cheerioWrapper = cheerioWrapper.parents();
}
function test_parent() {
cheerioWrapper = cheerioWrapper.parent();
}
function test_closest() {
cheerioWrapper = cheerioWrapper.closest('.selector');
cheerioWrapper = cheerioWrapper.closest(MyComponent);
}
function test_text() {
stringVal = cheerioWrapper.text();
}
function test_html() {
stringVal = cheerioWrapper.html();
}
function test_get() {
reactElement = cheerioWrapper.get(1);
}
function test_at() {
cheerioWrapper = cheerioWrapper.at(1);
}
function test_first() {
cheerioWrapper = cheerioWrapper.first();
}
function test_last() {
cheerioWrapper = cheerioWrapper.last();
}
function test_state() {
cheerioWrapper.state();
cheerioWrapper.state('key');
}
function test_props() {
objectVal = cheerioWrapper.props();
}
function test_prop() {
cheerioWrapper.prop('key');
}
function test_simulate(...args: any[]) {
cheerioWrapper.simulate('click');
cheerioWrapper.simulate('click', args);
}
function test_setState() {
cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'});
}
function test_setProps() {
cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'});
}
function test_setContext() {
cheerioWrapper = cheerioWrapper.setContext({name: 'baz'});
}
function test_instance() {
var myComponent: MyComponent = cheerioWrapper.instance();
}
function test_update() {
cheerioWrapper = cheerioWrapper.update();
}
function test_debug() {
stringVal = cheerioWrapper.debug();
}
function test_type() {
var stringOrFunction: String|Function = cheerioWrapper.type();
}
function test_forEach() {
cheerioWrapper =
cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_map() {
var arrayVal: Array<any> =
cheerioWrapper.map((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>)=> {
});
}
function test_reduce() {
const total: number[] =
cheerioWrapper.reduce<number>(
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_reduceRight() {
const total: number[] =
cheerioWrapper.reduceRight<number>(
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
);
}
function test_some() {
boolVal = cheerioWrapper.some('.selector');
boolVal = cheerioWrapper.some(MyComponent);
}
function test_someWhere() {
boolVal = cheerioWrapper.someWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_every() {
boolVal = cheerioWrapper.every('.selector');
boolVal = cheerioWrapper.every(MyComponent);
}
function test_everyWhere() {
boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
}
}
+340
View File
@@ -0,0 +1,340 @@
// Type definitions for Enzyme v1.2.0
// Project: https://github.com/airbnb/enzyme
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../react/react.d.ts" />
declare module "enzyme" {
import {ReactElement, Component} from "react";
export class ElementClass extends Component<any, any> {
}
/**
* Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the
* following three categories:
*
* 1. A Valid CSS Selector
* 2. A React Component Constructor
* 3. A React Component's displayName
*/
export type EnzymeSelector = String | typeof ElementClass;
interface CommonWrapper<T, P, S> {
/**
* Find every node in the render tree that matches the provided selector.
* @param selector The selector to match.
*/
find(selector: EnzymeSelector): T;
/**
* Finds every node in the render tree that returns true for the provided predicate function.
* @param predicate
*/
findWhere(predicate: (shallowWrapper: ShallowWrapper<P, S>) => Boolean): T;
/**
* Removes nodes in the current wrapper that do not match the provided selector.
* @param selector The selector to match.
*/
filter(selector: EnzymeSelector): T;
/**
* Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true.
* @param predicate
*/
filterWhere(predicate: (shallowWrapper: ShallowWrapper<P, S>) => Boolean): T;
/**
* Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in.
* @param node
*/
contains(node: ReactElement<any>): Boolean;
/**
* Returns whether or not the current node has a className prop including the passed in class name.
* @param className
*/
hasClass(className: String): Boolean;
/**
* Returns whether or not the current node matches a provided selector.
* @param selector
*/
is(selector: EnzymeSelector): Boolean;
/**
* Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector.
* This method is effectively the negation or inverse of filter.
* @param selector
*/
not(selector: EnzymeSelector): T;
/**
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
* can be provided and it will filter the children by this selector.
* @param [selector]
*/
children(selector?: EnzymeSelector): T;
/**
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
*
* Note: can only be called on a wrapper of a single node.
* @param [selector]
*/
parents(selector?: EnzymeSelector): T;
/**
* Returns a wrapper with the direct parent of the node in the current wrapper.
*/
parent(): T;
/**
* Returns a wrapper of the first element that matches the selector by traversing up through the current node's
* ancestors in the tree, starting with itself.
*
* Note: can only be called on a wrapper of a single node.
* @param selector
*/
closest(selector: EnzymeSelector): T;
/**
* Returns a string of the rendered text of the current render tree. This function should be looked at with
* skepticism if being used to test what the actual HTML output of the component will be. If that is what you
* would like to test, use enzyme's render function instead.
*
* Note: can only be called on a wrapper of a single node.
*/
text(): String;
/**
* Returns a string of the rendered HTML markup of the current render tree.
*
* Note: can only be called on a wrapper of a single node.
*/
html(): String;
/**
* Returns the node at a given index of the current wrapper.
* @param index
*/
get(index: number): ReactElement<any>;
/**
* Returns a wrapper around the node at a given index of the current wrapper.
* @param index
*/
at(index: number): T;
/**
* Reduce the set of matched nodes to the first in the set.
*/
first(): T;
/**
* Reduce the set of matched nodes to the last in the set.
*/
last(): T;
/**
* Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.
* @param [key]
*/
state(key?: String): any;
/**
* Returns the props hash for the current node of the wrapper.
*
* NOTE: can only be called on a wrapper of a single node.
*/
props(): Object;
/**
* Returns the prop value for the node of the current wrapper with the provided key.
*
* NOTE: can only be called on a wrapper of a single node.
* @param key
*/
prop(key: String): any;
/**
* Simulate events.
* Returns itself.
* @param event
* @param args?
*/
simulate(event: String, ...args: any[]): T;
/**
* A method to invoke setState() on the root component instance similar to how you might in the definition of
* the component, and re-renders. This method is useful for testing your component in hard to achieve states,
* however should be used sparingly. If possible, you should utilize your component's external API in order to
* get it into whatever state you want to test, in order to be as accurate of a test as possible. This is not
* always practical, however.
* Returns itself.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
* @param state
*/
setState(state: S): T;
/**
* A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test
* how the component behaves over time with changing props. Calling this, for instance, will call the
* componentWillReceiveProps lifecycle method.
*
* Similar to setState, this method accepts a props object and will merge it in with the already existing props.
* Returns itself.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
* @param state
*/
setProps(state: Object): T;
/**
* A method that sets the context of the root component, and re-renders. Useful for when you are wanting to
* test how the component behaves over time with changing contexts.
* Returns itself.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
* @param state
*/
setContext(state: Object): T;
/**
* Gets the instance of the component being rendered as the root node passed into shallow().
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
*/
instance(): Component<P, S>;
/**
* Forces a re-render. Useful to run before checking the render output if something external may be updating
* the state of the component somewhere.
* Returns itself.
*
* NOTE: can only be called on a wrapper instance that is also the root instance.
*/
update(): T;
/**
* Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when
* tests are not passing when you expect them to.
*/
debug(): String;
/**
* Returns the type of the current node of this wrapper. If it's a composite component, this will be the
* component constructor. If it's native DOM node, it will be a string of the tag name.
*
* Note: can only be called on a wrapper of a single node.
*/
type(): String | Function;
/**
* Iterates through each node of the current wrapper and executes the provided function with a wrapper around
* the corresponding node passed in as the first argument.
*
* Returns itself.
* @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first
* argument, and will be run with a context of the original instance.
*/
forEach(fn: (wrapper: ShallowWrapper<P, S>) => void): T;
/**
* Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map
* function.
* Returns an array of the returned values from the mapping function..
* @param fn A mapping function to be run for every node in the collection, the results of which will be mapped
* to the returned array. Should expect a ShallowWrapper as the first argument, and will be run
* with a context of the original instance.
*/
map(fn: (wrapper: ShallowWrapper<P, S>) => any): Array<any>;
/**
* Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node
* is passed in as a ShallowWrapper, and is processed from left to right.
* @param fn
* @param initialValue
*/
reduce<R>(fn: (prevVal: R, wrapper: ShallowWrapper<P, S>, index: number) => R, initialValue?: R): R[];
/**
* Applies the provided reducing function to every node in the wrapper to reduce to a single value.
* Each node is passed in as a ShallowWrapper, and is processed from right to left.
* @param fn
* @param initialValue
*/
reduceRight<R>(fn: (prevVal: R, wrapper: ShallowWrapper<P, S>, index: number) => R, initialValue?: R): R[];
/**
* Returns whether or not any of the nodes in the wrapper match the provided selector.
* @param selector
*/
some(selector: EnzymeSelector): Boolean;
/**
* Returns whether or not any of the nodes in the wrapper pass the provided predicate function.
* @param fn
*/
someWhere(fn: (wrapper: ShallowWrapper<P, S>) => Boolean): Boolean;
/**
* Returns whether or not all of the nodes in the wrapper match the provided selector.
* @param selector
*/
every(selector: EnzymeSelector): Boolean;
/**
* Returns whether or not any of the nodes in the wrapper pass the provided predicate function.
* @param fn
*/
everyWhere(fn: (wrapper: ShallowWrapper<P, S>) => Boolean): Boolean;
length: number;
}
export interface ShallowWrapper<P, S> extends CommonWrapper<ShallowWrapper<P, S>, P, S> {
shallow(): ShallowWrapper<P, S>;
render(): CheerioWrapper<P, S>;
}
export interface ReactWrapper<P, S> extends CommonWrapper<ReactWrapper<P, S>, P, S> {
}
export interface CheerioWrapper<P, S> extends CommonWrapper<CheerioWrapper<P, S>, P, S> {
}
/**
* Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that
* your tests aren't indirectly asserting on behavior of child components.
* @param node
* @param [options]
*/
export function shallow<P, S>(node: ReactElement<P>, options?: any): ShallowWrapper<P, S>;
/**
* Mounts and renders a react component into the document and provides a testing wrapper around it.
* @param node
* @param [options]
*/
export function mount<P, S>(node: ReactElement<P>, options?: any): ReactWrapper<P, S>;
/**
* Render react components to static HTML and analyze the resulting HTML structure.
* @param node
* @param [options]
*/
export function render<P, S>(node: ReactElement<P>, options?: any): CheerioWrapper<P, S>;
export function describeWithDOM(description: String, fn: Function): void;
export function spyLifecycle(component: typeof Component): void;
}
+4 -3
View File
@@ -1,7 +1,8 @@
/// <reference path="errorhandler.d.ts" />
import express = require('express');
import errorhandler = require('errorhandler');
import * as express from 'express';
import * as errorhandler from 'errorhandler';
var app = express();
app.use(errorhandler());
@@ -14,4 +15,4 @@ app.use(errorhandler({ log: (err, str, req, res) => {
const requestWasFresh = req && req.fresh;
const responseContentType = res && res.contentType
}}))
}}))
+6 -6
View File
@@ -6,19 +6,19 @@
/// <reference path="../express/express.d.ts" />
declare module "errorhandler" {
import express = require('express');
import * as express from 'express';
function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler;
namespace errorHandler {
interface LoggingCallback {
(err: Error, str: string, req: express.Request, res: express.Response): void;
}
interface Options {
/**
* Defaults to true.
*
*
* Possible values:
* true : Log errors using console.error(str).
* false : Only send the error back in the response.
@@ -27,6 +27,6 @@ declare module "errorhandler" {
log: boolean | LoggingCallback;
}
}
export = errorHandler;
}
+4 -1
View File
@@ -35,7 +35,10 @@ class EventEmitterTest {
constructor() {
this.v = new EventEmitter();
this.v = new EventEmitter3ImportedAsES6Module();
var n: NodeJS.EventEmitter = this.v;
// Some methods are missing or incompatible with current implementation (v4.2.x) of NodeJS.EventEmitter
// (e.g. getMaxListenters or listeners)
// var n: NodeJS.EventEmitter = this.v;
}
listeners() {
+14 -20
View File
@@ -143,26 +143,20 @@ class MyTable4 extends React.Component<{}, MyTable4State> {
headerHeight={50}
width={1000}
height={500}>
<Column
header={<Cell>Name</Cell>}
cell={
<MyTextCell
data={this.state.tableData}
field="name"
/>
}
width={200}/>
<Column
header={<Cell>Email</Cell>}
cell={
<MyLinkCell
data={this.state.tableData}
field="email"
/>
}
width={200}
/>
{
["name", "email"].map(field =>
<Column
key={field}
header={<Cell>{field}</Cell>}
cell={
<MyTextCell
data={this.state.tableData}
field={field}
/>
}
width={200}/>
)
}
</Table>
);
}
+2 -2
View File
@@ -249,7 +249,7 @@ declare module FixedDataTable {
/**
* Component that defines the attributes of table column.
*/
interface ColumnProps {
interface ColumnProps extends __React.Props<Column> {
/**
* The horizontal alignment of the table cell content.
*
@@ -498,4 +498,4 @@ declare module FixedDataTable {
declare module "fixed-data-table" {
export = FixedDataTable;
}
}
+2
View File
@@ -92,6 +92,8 @@ declare module jquery.flot {
interface axisOptions {
show?: boolean; // null or true/false
position?: string; // "bottom" or "top" or "left" or "right"
mode?: string; // "time"
monthNames?: string[]; // array of month names
color?: any; // null or color spec
tickColor?: any; // null or color spec
+1
View File
@@ -497,6 +497,7 @@ declare module freedom.Social {
interface UserProfile {
userId: string;
name: string;
status?: number;
url?: string;
// Image URI (e.g. data:image/png;base64,adkwe329...)
imageData?: string;
@@ -19,6 +19,8 @@ import {
shell
} from 'electron';
require('electron').hideInternalModules();
import path = require('path');
// Quick start
@@ -201,7 +203,7 @@ ipcMain.on('online-status-changed', (event: any, status: any) => {
app.on('ready', () => {
window = new BrowserWindow({
width: 800,
height: 600,
height: 600,
titleBarStyle: 'hidden-inset',
});
window.loadURL('https://github.com');
+35 -20
View File
@@ -70,9 +70,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): Screen;
removeListener(event: string, listener: Function): Screen;
removeAllListeners(event?: string): Screen;
setMaxListeners(n: number): void;
setMaxListeners(n: number): Screen;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* @returns The current absolute position of the mouse pointer.
*/
@@ -108,9 +110,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): WebContents;
removeListener(event: string, listener: Function): WebContents;
removeAllListeners(event?: string): WebContents;
setMaxListeners(n: number): void;
setMaxListeners(n: number): WebContents;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
constructor(options?: BrowserWindowOptions);
/**
* @returns All opened browser windows.
@@ -522,9 +526,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): WebContents;
removeListener(event: string, listener: Function): WebContents;
removeAllListeners(event?: string): WebContents;
setMaxListeners(n: number): void;
setMaxListeners(n: number): WebContents;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* Loads the url in the window.
* @param url Must contain the protocol prefix (e.g., the http:// or file://).
@@ -930,9 +936,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): App;
removeListener(event: string, listener: Function): App;
removeAllListeners(event?: string): App;
setMaxListeners(n: number): void;
setMaxListeners(n: number): App;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* Try to close all windows. The before-quit event will first be emitted.
* If all windows are successfully closed, the will-quit event will be emitted
@@ -1122,9 +1130,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): AutoUpdater;
removeListener(event: string, listener: Function): AutoUpdater;
removeAllListeners(event?: string): AutoUpdater;
setMaxListeners(n: number): void;
setMaxListeners(n: number): AutoUpdater;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* Set the url and initialize the auto updater.
* The url cannot be changed once it is set.
@@ -1232,9 +1242,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): Tray;
removeListener(event: string, listener: Function): Tray;
removeAllListeners(event?: string): Tray;
setMaxListeners(n: number): void;
setMaxListeners(n: number): Tray;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* Creates a new tray icon associated with the image.
*/
@@ -1312,7 +1324,7 @@ declare module GitHubElectron {
*/
read(format: string, type?: string): any;
}
interface CrashReporterStartOptions {
/**
* Default: Electron
@@ -1343,7 +1355,7 @@ declare module GitHubElectron {
*/
extra?: {}
}
interface CrashReporterPayload extends Object {
/**
* E.g., "electron-crash-service".
@@ -1383,17 +1395,17 @@ declare module GitHubElectron {
*/
upload_file_minidump: File;
}
interface CrashReporter {
start(options?: CrashReporterStartOptions): void;
/**
* @returns The date and ID of the last crash report. When there was no crash report
* sent or the crash reporter is not started, null will be returned.
*/
getLastCrashReport(): CrashReporterPayload;
}
interface Shell{
/**
* Show the given file in a file manager. If possible, select the file.
@@ -1426,9 +1438,11 @@ declare module GitHubElectron {
once(event: string, listener: Function): IpcRenderer;
removeListener(event: string, listener: Function): IpcRenderer;
removeAllListeners(event?: string): IpcRenderer;
setMaxListeners(n: number): void;
setMaxListeners(n: number): IpcRenderer;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
/**
* Send ...args to the renderer via channel in asynchronous message, the main
* process can handle it by listening to the channel event of ipc module.
@@ -1469,7 +1483,7 @@ declare module GitHubElectron {
*/
process: any;
}
interface WebFrame {
/**
* Changes the zoom factor to the specified factor, zoom factor is
@@ -1588,7 +1602,7 @@ declare module GitHubElectron {
ENABLE_SAMPLING: number;
RECORD_CONTINUOUSLY: number;
}
interface Dialog {
/**
* @param callback If supplied, the API call will be asynchronous.
@@ -1608,7 +1622,7 @@ declare module GitHubElectron {
* @returns The index of the clicked button.
*/
showMessageBox: typeof GitHubElectron.Dialog.showMessageBox;
/**
* Runs a modal dialog that shows an error message. This API can be called safely
* before the ready event of app module emits, it is usually used to report errors
@@ -1616,7 +1630,7 @@ declare module GitHubElectron {
*/
showErrorBox(title: string, content: string): void;
}
interface GlobalShortcut {
/**
* Registers a global shortcut of accelerator.
@@ -1643,14 +1657,14 @@ declare module GitHubElectron {
*/
unregisterAll(): void;
}
class RequestFileJob {
/**
* Create a request job which would query a file of path and set corresponding mime types.
*/
constructor(path: string);
}
class RequestStringJob {
/**
* Create a request job which sends a string as response.
@@ -1667,7 +1681,7 @@ declare module GitHubElectron {
data?: string;
});
}
class RequestBufferJob {
/**
* Create a request job which accepts a buffer and sends a string as response.
@@ -1684,7 +1698,7 @@ declare module GitHubElectron {
data?: Buffer;
});
}
interface Protocol {
registerProtocol(scheme: string, handler: (request: any) => void): void;
unregisterProtocol(scheme: string): void;
@@ -1718,6 +1732,7 @@ declare module GitHubElectron {
powerMonitor: NodeJS.EventEmitter;
protocol: GitHubElectron.Protocol;
Tray: typeof GitHubElectron.Tray;
hideInternalModules(): void;
}
}
+61
View File
@@ -77,23 +77,84 @@ interface StepDefinition {
}
interface HopscotchStatic {
/**
* Actually starts the tour. Optional stepNum argument specifies what step to start at.
*/
startTour(tour: TourDefinition, stepNum?: number): void;
/**
* Skips to a given step in the tour
*/
showStep(id: number): void;
/**
* Goes back one step in the tour
*/
prevStep(): void;
/**
* Goes forward one step in the tour
*/
nextStep(): void;
/**
* Ends the current tour. If clearCookie is set to false, the tour state is preserved.
* Otherwise, if clearCookie is set to true or is not provided, the tour state is cleared.
*/
endTour(clearCookie: boolean): void;
/**
* Sets options for running the tour.
*/
configure(options: HopscotchConfiguration): void;
/**
* Returns the currently running tour.
*/
getCurrTour(): TourDefinition;
/**
* Returns the currently running tour.
*/
getCurrStepNum(): number;
/**
* Checks for tour state saved in sessionStorage/cookies and returns the state if
* it exists. Use this method to determine whether or not you should resume a tour.
*/
getState(): string;
/**
* Adds a callback for one of the event types. Valid event types are:
* *start*, *end*, *next*, *prev*, *show*, *close*, *error*
*/
listen(eventName: string, callback: () => void): void;
/**
* Removes a callback for one of the event types.
*/
unlisten(eventName: string, callback: () => void): void;
/**
* Remove callbacks for hopscotch events. If tourOnly is set to true, only removes
* callbacks specified by a tour (callbacks set by hopscotch.configure or hopscotch.listen
* will remain). If eventName is null or undefined, callbacks for all events will be removed.
*/
removeCallbacks(eventName?: string, tourOnly?: boolean): void;
/**
* Registers a callback helper. See the section about Helpers below.
*/
registerHelper(id: string, helper: (...args: any[]) => void): void;
/**
* Resets i18n strings to original default values.
*/
resetDefaultI18N(): void;
/**
* Resets all config options to original values.
*/
resetDefaultOptions(): void;
}
+4 -2
View File
@@ -1,8 +1,8 @@
/// <reference path="http-errors.d.ts" />
/// <reference path="../express/express.d.ts" />
import createError = require('http-errors');
import express = require('express');
import * as createError from 'http-errors';
import * as express from 'express';
var app = express();
@@ -67,3 +67,5 @@ var err = new createError['404']();
//createError['404'](); // TypeScript should fail with "Did you mean to include 'new'?"
//new createError(); // TypeScript should fail with "Only a void function can be called with the 'new' keyword"
let error: createError.HttpError;
+80 -76
View File
@@ -4,82 +4,86 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'http-errors' {
interface HttpError extends Error {
status: number;
statusCode: number;
expose: boolean;
namespace createHttpError {
// See https://github.com/jshttp/http-errors/blob/1.3.1/index.js#L42
interface HttpError extends Error {
status: number;
statusCode: number;
expose: boolean;
}
interface CreateHttpError {
// See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674
[code: string]: new() => HttpError;
(...args: Array<Error | string | number | Object>): HttpError;
Continue: new() => HttpError;
SwitchingProtocols: new() => HttpError;
Processing: new() => HttpError;
OK: new() => HttpError;
Created: new() => HttpError;
Accepted: new() => HttpError;
NonAuthoritativeInformation: new() => HttpError;
NoContent: new() => HttpError;
ResetContent: new() => HttpError;
PartialContent: new() => HttpError;
MultiStatus: new() => HttpError;
AlreadyReported: new() => HttpError;
IMUsed: new() => HttpError;
MultipleChoices: new() => HttpError;
MovedPermanently: new() => HttpError;
Found: new() => HttpError;
SeeOther: new() => HttpError;
NotModified: new() => HttpError;
UseProxy: new() => HttpError;
Unused: new() => HttpError;
TemporaryRedirect: new() => HttpError;
PermanentRedirect: new() => HttpError;
BadRequest: new() => HttpError;
Unauthorized: new() => HttpError;
PaymentRequired: new() => HttpError;
Forbidden: new() => HttpError;
NotFound: new() => HttpError;
MethodNotAllowed: new() => HttpError;
NotAcceptable: new() => HttpError;
ProxyAuthenticationRequired: new() => HttpError;
RequestTimeout: new() => HttpError;
Conflict: new() => HttpError;
Gone: new() => HttpError;
LengthRequired: new() => HttpError;
PreconditionFailed: new() => HttpError;
PayloadTooLarge: new() => HttpError;
URITooLong: new() => HttpError;
UnsupportedMediaType: new() => HttpError;
RangeNotSatisfiable: new() => HttpError;
ExpectationFailed: new() => HttpError;
ImATeapot: new() => HttpError;
UnprocessableEntity: new() => HttpError;
Locked: new() => HttpError;
FailedDependency: new() => HttpError;
UnorderedCollection: new() => HttpError;
UpgradeRequired: new() => HttpError;
PreconditionRequired: new() => HttpError;
TooManyRequests: new() => HttpError;
RequestHeaderFieldsTooLarge: new() => HttpError;
UnavailableForLegalReasons: new() => HttpError;
InternalServerError: new() => HttpError;
NotImplemented: new() => HttpError;
BadGateway: new() => HttpError;
ServiceUnavailable: new() => HttpError;
GatewayTimeout: new() => HttpError;
HTTPVersionNotSupported: new() => HttpError;
VariantAlsoNegotiates: new() => HttpError;
InsufficientStorage: new() => HttpError;
LoopDetected: new() => HttpError;
BandwidthLimitExceeded: new() => HttpError;
NotExtended: new() => HttpError;
NetworkAuthenticationRequired: new() => HttpError;
}
}
interface CreateHttpError {
// See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674
[code: string]: new() => HttpError;
(...args: Array<Error | string | number | Object>): HttpError;
Continue: new() => HttpError;
SwitchingProtocols: new() => HttpError;
Processing: new() => HttpError;
OK: new() => HttpError;
Created: new() => HttpError;
Accepted: new() => HttpError;
NonAuthoritativeInformation: new() => HttpError;
NoContent: new() => HttpError;
ResetContent: new() => HttpError;
PartialContent: new() => HttpError;
MultiStatus: new() => HttpError;
AlreadyReported: new() => HttpError;
IMUsed: new() => HttpError;
MultipleChoices: new() => HttpError;
MovedPermanently: new() => HttpError;
Found: new() => HttpError;
SeeOther: new() => HttpError;
NotModified: new() => HttpError;
UseProxy: new() => HttpError;
Unused: new() => HttpError;
TemporaryRedirect: new() => HttpError;
PermanentRedirect: new() => HttpError;
BadRequest: new() => HttpError;
Unauthorized: new() => HttpError;
PaymentRequired: new() => HttpError;
Forbidden: new() => HttpError;
NotFound: new() => HttpError;
MethodNotAllowed: new() => HttpError;
NotAcceptable: new() => HttpError;
ProxyAuthenticationRequired: new() => HttpError;
RequestTimeout: new() => HttpError;
Conflict: new() => HttpError;
Gone: new() => HttpError;
LengthRequired: new() => HttpError;
PreconditionFailed: new() => HttpError;
PayloadTooLarge: new() => HttpError;
URITooLong: new() => HttpError;
UnsupportedMediaType: new() => HttpError;
RangeNotSatisfiable: new() => HttpError;
ExpectationFailed: new() => HttpError;
ImATeapot: new() => HttpError;
UnprocessableEntity: new() => HttpError;
Locked: new() => HttpError;
FailedDependency: new() => HttpError;
UnorderedCollection: new() => HttpError;
UpgradeRequired: new() => HttpError;
PreconditionRequired: new() => HttpError;
TooManyRequests: new() => HttpError;
RequestHeaderFieldsTooLarge: new() => HttpError;
UnavailableForLegalReasons: new() => HttpError;
InternalServerError: new() => HttpError;
NotImplemented: new() => HttpError;
BadGateway: new() => HttpError;
ServiceUnavailable: new() => HttpError;
GatewayTimeout: new() => HttpError;
HTTPVersionNotSupported: new() => HttpError;
VariantAlsoNegotiates: new() => HttpError;
InsufficientStorage: new() => HttpError;
LoopDetected: new() => HttpError;
BandwidthLimitExceeded: new() => HttpError;
NotExtended: new() => HttpError;
NetworkAuthenticationRequired: new() => HttpError;
}
var httpError: CreateHttpError;
export = httpError;
var createHttpError: createHttpError.CreateHttpError;
export = createHttpError;
}
+3 -1
View File
@@ -246,9 +246,11 @@ declare module IMAP {
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): void;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
// 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. */
+4 -2
View File
@@ -149,6 +149,7 @@ class IonicTestController {
ionicModalController.initialize(modalOptions);
ionicModalController.show().then(() => console.log("shown modal"))
ionicModalController.hide().then(() => console.log("hid modal"))
ionicModalController.remove().then(() => console.log("removed modal"))
var isShown: boolean = ionicModalController.isShown();
this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions)
@@ -199,8 +200,9 @@ class IonicTestController {
};
var ionicPopoverController: ionic.popover.IonicPopoverController = this.$ionicPopover.fromTemplate("template", popoverOptions);
ionicPopoverController.initialize(popoverOptions);
ionicPopoverController.show(angular.element("body")).then(() => console.log("shown popover"))
ionicPopoverController.hide().then(() => console.log("hid popover"))
ionicPopoverController.show(angular.element("body")).then(() => console.log("shown popover"));
ionicPopoverController.hide().then(() => console.log("hid popover"));
ionicPopoverController.remove().then(() => console.log("removed popover"));
var isShown: boolean = ionicPopoverController.isShown();
this.$ionicPopover.fromTemplateUrl("templateUrl", popoverOptions)
+2
View File
@@ -174,6 +174,7 @@ declare module ionic {
initialize(options: IonicModalOptions): void;
show(): ng.IPromise<void>;
hide(): ng.IPromise<void>;
remove(): ng.IPromise<void>;
isShown(): boolean;
}
@@ -237,6 +238,7 @@ declare module ionic {
show($event?: any): ng.IPromise<any>;
hide(): ng.IPromise<any>;
isShown(): boolean;
remove(): ng.IPromise<any>;
}
interface IonicPopoverOptions {
scope?: any;
+2 -2
View File
@@ -1,10 +1,10 @@
/// <reference path="jade.d.ts"/>
import jade from 'jade';
import * as jade from 'jade';
jade.compile("b")();
jade.compileFile("foo.jade", {})();
jade.compileClient("a")({ a: 1 });
jade.compileClientWithDependenciesTracked("test").body();
jade.render("h1",{});
jade.renderFile("foo.jade");
jade.renderFile("foo.jade");
+9 -12
View File
@@ -4,16 +4,13 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'jade' {
module jade {
function compile(template: string, options?: any): (locals?: any) => string;
function compileFile(path: string, options?: any): (locals?: any) => string;
function compileClient(template: string, options?: any): (locals?: any) => string;
function compileClientWithDependenciesTracked(template: string, options?: any): {
body: (locals?: any) => string;
dependencies: string[];
};
function render(template: string, options?: any): string;
function renderFile(path: string, options?: any): string;
}
export default jade;
export function compile(template: string, options?: any): (locals?: any) => string;
export function compileFile(path: string, options?: any): (locals?: any) => string;
export function compileClient(template: string, options?: any): (locals?: any) => string;
export function compileClientWithDependenciesTracked(template: string, options?: any): {
body: (locals?: any) => string;
dependencies: string[];
};
export function render(template: string, options?: any): string;
export function renderFile(path: string, options?: any): string;
}
+3 -1
View File
@@ -231,9 +231,11 @@ declare module jake{
once(event: string, listener: Function): NodeJS.EventEmitter;
removeListener(event: string, listener: Function): NodeJS.EventEmitter;
removeAllListeners(event?: string): NodeJS.EventEmitter;
setMaxListeners(n: number): void;
setMaxListeners(n: number): NodeJS.EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
value: any;
}
+4 -4
View File
@@ -195,8 +195,8 @@ declare module jasmine {
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')
*/
//toContainHtml(html: string): boolean;
toContainHtml(html: string): boolean;
/**
* Check if DOM element has the given Text.
* @param text Accepts a string or regular expression
@@ -213,8 +213,8 @@ declare module jasmine {
* // returns true
* expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header')
*/
//toContainText(text: string): boolean;
toContainText(text: string): boolean;
/**
* Check if DOM element has the given value.
* This can only be applied for element on with jQuery val() can be called.
+6 -7
View File
@@ -281,7 +281,7 @@ declare module jasmine {
toBe(expected: any, expectationFailOutput?: any): boolean;
toEqual(expected: any, expectationFailOutput?: any): boolean;
toMatch(expected: any, expectationFailOutput?: any): boolean;
toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
toBeDefined(expectationFailOutput?: any): boolean;
toBeUndefined(expectationFailOutput?: any): boolean;
toBeNull(expectationFailOutput?: any): boolean;
@@ -291,13 +291,12 @@ declare module jasmine {
toHaveBeenCalled(): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toContain(expected: any, expectationFailOutput?: any): boolean;
toBeLessThan(expected: any, expectationFailOutput?: any): boolean;
toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean;
toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean;
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean;
toThrow(expected?: any): boolean;
toThrowError(expected?: any, message?: string): boolean;
toThrowError(message?: string | RegExp): boolean;
toThrowError(expected?: Error, message?: string | RegExp): boolean;
not: Matchers;
Any: Any;
@@ -0,0 +1,21 @@
/// <reference path="javascript-bignum.d.ts"/>
let m = SchemeNumber("1");
let n = SchemeNumber(2);
let sum: SchemeNumber = SchemeNumber.fn["+"](m, n);
sum = SchemeNumber.fn["+"](m, 1);
sum = SchemeNumber.fn["+"](m, "12");
sum = SchemeNumber.fn["+"]("12", "25");
let floored: SchemeNumber = SchemeNumber.fn.floor(m);
let str: string = floored.toString(16);
str = floored.toExponential(2);
str = floored.toPrecision(2);
str = floored.toFixed(2);
let num: number = maxIntegerDigits;
num = VERSION[0];
num = VERSION.length;
raise("fake error", "This is not really an error", m);
+53
View File
@@ -0,0 +1,53 @@
// Type definitions for javascript-bignum
// Project: https://github.com/jtobey/javascript-bignum
// Definitions by: Nathan Shively-Sanders <https://github.com/sandersn>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Documentation: http://john-edwin-tobey.org/Scheme/javascript-bignum/docs/files/schemeNumber-js.html
// This version only includes typing for schemeNumber, not the full library
declare type SchemeOperator = (...args: (string | SchemeNumber | number)[]) => SchemeNumber;
declare var VERSION: number[];
declare function raise(conditionType: string, message: string, ...irritants: any[]): void;
declare var maxIntegerDigits: number;
declare interface SchemeFn {
[opname: string]: SchemeOperator;
inexact: SchemeOperator;
exact: SchemeOperator;
max: SchemeOperator;
min: SchemeOperator;
abs: SchemeOperator;
div: SchemeOperator;
mod: SchemeOperator;
div0: SchemeOperator;
mod0: SchemeOperator;
gcd: SchemeOperator;
lcm: SchemeOperator;
numerator: SchemeOperator;
denominator: SchemeOperator;
floor: SchemeOperator;
ceiling: SchemeOperator;
truncate: SchemeOperator;
round: SchemeOperator;
rationalize: SchemeOperator;
exp: SchemeOperator;
log: SchemeOperator;
sin: SchemeOperator;
cos: SchemeOperator;
tan: SchemeOperator;
asin: SchemeOperator;
acos: SchemeOperator;
atan: SchemeOperator;
sqrt: SchemeOperator;
expt: SchemeOperator;
magnitude: SchemeOperator;
angle: SchemeOperator;
}
declare interface SchemeNumber {
(value: string | number): SchemeNumber;
toString(radix: number): string;
toFixed(fractionDigits: number): string;
toExponential(fractionDigits: number): string;
toPrecision(precision: number): string;
fn: SchemeFn;
}
declare var SchemeNumber: SchemeNumber;
+2
View File
@@ -579,7 +579,9 @@ objSchema = objSchema.without(str, strArr);
objSchema = objSchema.rename(str, str);
objSchema = objSchema.rename(str, str, renOpts);
objSchema = objSchema.assert(str, schema);
objSchema = objSchema.assert(str, schema, str);
objSchema = objSchema.assert(ref, schema);
objSchema = objSchema.assert(ref, schema, str);
objSchema = objSchema.unknown();
+3 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for joi v4.6.0
// Project: https://github.com/spumko/joi
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Laurence Dougal Myers <https://github.com/laurence-myers>, Christopher Glantschnig <https://github.com/cglantschnig>
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Laurence Dougal Myers <https://github.com/laurence-myers>, Christopher Glantschnig <https://github.com/cglantschnig>, David Broder-Rodgers <https://github.com/DavidBR-SW>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TODO express type of Schema in a type-parameter (.default, .valid, .example etc)
@@ -584,8 +584,8 @@ declare module 'joi' {
/**
* Verifies an assertion where.
*/
assert(ref: string, schema: Schema, message: string): ObjectSchema;
assert(ref: Reference, schema: Schema, message: string): ObjectSchema;
assert(ref: string, schema: Schema, message?: string): ObjectSchema;
assert(ref: Reference, schema: Schema, message?: string): ObjectSchema;
/**
* Overrides the handling of unknown keys for the scope of the current object only (does not apply to children).
+85
View File
@@ -0,0 +1,85 @@
///<reference path="../jquery/jquery.d.ts" />
///<reference path="../jquery.mmenu/jquery.mmenu.d.ts" />
// --------------------------------------------------------
// ---------------- TEST DEFAULT OPTIONS ------------------
// --------------------------------------------------------
var menu: JQuery = $("#my-menu");
menu.mmenu(
// options
{
extensions: [],
navbar: {
add: true,
title: "Menu",
titleLink: "parent"
},
onClick: {
close: true,
preventDefault: false,
setSelected: false
},
slidingSubmenus: true
},
// configurations
{
classNames: {
divider: "Divider",
inset: "Inset",
panel: "Panel",
selected: "Selected",
vertical: "vertical"
},
clone: false,
openingInterval: 25,
panelNodetype: "div, ul, ol",
transitionDuration: 400
}
);
// --------------------------------------------------------
// ------------------- TEST MMENU API ---------------------
// --------------------------------------------------------
var api = menu.data("mmenu");
var myPanel: JQuery = $("#panel");
var listItem: JQuery = $(".list-item");
api.closeAllPanels();
api.bind("closeAllPanels", function() {
console.log("close all opened panels and go back to the first panel.");
});
api.closePanel(myPanel);
api.bind("closePanel", function(panel) {
console.log("close this ", panel);
});
api.getInstance();
api.bind("getInstance", function() {
console.log("get the class instance for the menu.");
});
api.init(myPanel);
api.bind("init", function(panel) {
console.log("method to (re)initialize a newly added ", panel);
});
api.openPanel(myPanel);
api.bind("openPanel", function(panel) {
console.log("This panel is now opened ", panel);
});
api.setSelected(listItem, true);
api.bind("setSelected", function(listItem, selected) {
console.log("set or unset a list item as selected ", listItem);
console.log("has selected ", selected);
});
api.update();
api.bind("update", function() {
console.log("update the appearance for the menu");
});
+242
View File
@@ -0,0 +1,242 @@
// Type definitions for jQuery mmenu v5.5.3
// Project: http://mmenu.frebsite.nl/
// Definitions by: John Gouigouix <https://github.com/orchestra-ts/DefinitelyTyped/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
declare module JQueryMmenu {
interface NavbarOptions {
/**
* Whether or not to add a navbar above the panels.
* Default: true
*/
add?: boolean;
/**
* The title above the main panel.
* Default: "Menu"
*/
title?: string;
/**
* The type of link to set for the title.
* Possible values: "parent", "anchor" or "none".
* Default: "parent"
*/
titleLink?: string;
}
interface OnclickOptions {
/**
* Whether or not the menu should close after clicking a link inside it.
* The default value varies per link: true if the default behavior for
* the clicked link is prevented, false otherwise.
* Default: null
*/
close?: boolean | any;
/**
* Whether or not to prevent the default behavior for the clicked link.
* The default value varies per link: true if its href is equal to
* or starts with a hash (#), false otherwise.
* Default: null
*/
preventDefault?: boolean | any;
/**
* Whether or not the clicked link should be visibly "selected".
* Default: true
*/
setSelected?: boolean | any;
}
interface Options {
/**
* A collection of extension names to enable for the menu.
* You'll need this option when using the extensions.
* Default: []
*/
extensions?: Array<Object>;
/**
* navbar options
*/
navbar?: NavbarOptions;
/**
* onClick options
*/
onClick?: OnclickOptions;
/**
* Whether or not submenus should come sliding in from the right.
* If false, submenus expand below their parent.
* To expand a single submenu below its parent item, add the class "Vertical" to it.
* Default: true
*/
slidingSubmenus?: boolean;
}
interface ClassnamesConfigurations {
/**
* The classname on a LI that should be displayed as a divider.
* Default: "Divider"
*/
divider?: string;
/**
* The classname on a submenu (a nested UL) that should be displayed as a default list.
* Default: "Inset"
*/
inset?: string;
/**
* The classname on an element (for example a DIV) that should be considered to be a panel.
* Only applies if the "isMenu" option is set to false.
* Default: "Panel"
*/
panel?: string;
/**
* The classname on the LI that should be displayed as selected.
* Default: "Selected"
*/
selected?: string;
/**
* The classname on a submenu (a nested UL) that should expand below
* their parent instead of slide in from the right.
* Default: "vertical"
*/
vertical?: string;
}
interface Configurations {
/**
* the CSS class names object
*/
classNames?: ClassnamesConfigurations;
/**
* Whether or not the menu should be cloned (and the original menu kept intact).
* Default: false
*/
clone?: boolean;
/**
* The number of milliseconds between opening/closing the menu and panels,
* needed to force CSS transitions.
* Default: 25
*/
openingInterval?: number;
/**
* jQuery selector containing the node-type of panels.
* Default: "div, ul, ol"
*/
panelNodetype?: string;
/**
* The number of milliseconds used in the CSS transitions.
* Default: 400 (The value should match the associated CSS value.)
*/
transitionDuration?: number;
}
interface API {
/**
* Trigger non-specialized signature method
* @param methodName
* @param callback
*/
bind(methodName: string, callback: (...args: any[]) => void): any;
/**
* Trigger this method to close all opened panels and go back to the first panel.
*/
closeAllPanels(): JQuery;
/** @see closeAllPanels() */
bind(methodName: "closeAllPanels", callback: () => void): JQuery;
/**
* Trigger this method to close a panel
* (only available if the "slidingSubmenus" option is set to false).
* @param panel
*/
closePanel(panel: JQuery): void;
/** @see closePanel() */
bind(methodName: "closePanel", callback: (panel: JQuery) => void): void;
/**
* Trigger this method to get the class instance for the menu.
*/
getInstance(): void;
/** @see getInstance() */
bind(methodName: "getInstance", callback: () => void): void;
/**
* Trigger this method to (re)initialize a newly added panel.
* @param panel The panel to (re)initialize.
*/
init(panel: JQuery): void;
/** @see init() */
bind(methodName: "init", callback: (panel: JQuery) => void): void;
/**
* Trigger this method to open a panel.
* @param panel The panel to open.
*/
openPanel(panel: JQuery): void;
/** @see openPanel() */
bind(methodName: "openPanel", callback: (panel: JQuery) => void): void;
/**
* Trigger this method to set or unset a list item as "selected".
* @param li The list item to set or unset as "selected".
* @param selected Whether to set or unset the list item as "selected". Default: true
*/
setSelected(li: JQuery, selected?: boolean): void;
/** @see setSelected() */
bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void): void;
/**
* Trigger this method to update the appearance for the menu.
*/
update(): void;
/** @see update() */
bind(methodName: "update", callback: () => void): void;
}
}
interface JQuery {
/**
* Create mmenu component
*/
mmenu(): JQuery;
mmenu(options: JQueryMmenu.Options): JQuery;
mmenu(options: JQueryMmenu.Options, configurations: JQueryMmenu.Configurations): JQuery;
/**
* Return the mmenu object
* @param element
*/
data(element: "mmenu"): JQueryMmenu.API;
}
+1 -1
View File
@@ -49,7 +49,7 @@ declare module JQueryUI {
delay?: number;
disabled?: boolean;
minLength?: number;
position?: string;
position?: any; // object
source?: any; // [], string or ()
}
+10
View File
@@ -0,0 +1,10 @@
// Knockout specs depend on custom Jasmine matchers
// See https://github.com/knockout/knockout/blob/v3.4.0/spec/lib/jasmine.extensions.js
// FYI jasmine-jquery.d.ts (https://github.com/velesin/jasmine-jquery) also defines toContainHtml() and toContainText()
declare module jasmine {
interface Matchers {
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
}
}
@@ -1,4 +1,5 @@
/// <reference path="../../jasmine/jasmine.d.ts" />
/// <reference path="jasmine.extensions.d.ts" />
/// <reference path="../knockout.d.ts" />
/// <reference path="../../knockout.mapping/knockout.mapping.d.ts" />
+35
View File
@@ -0,0 +1,35 @@
/// <reference path="./lime-js.d.ts" />
var transport = new Lime.WebSocketTransport(true);
var clientChannel = new Lime.ClientChannel(transport, true, true);
clientChannel.onMessage = (m) => {
// message received callback
};
clientChannel.onNotification = (n) => {
// notification received callback
};
clientChannel.onCommand = (c) => {
// command received callback
};
transport.onOpen = () => {
var authentication: Lime.Authentication = new Lime.GuestAuthentication();
Lime.ClientChannelExtensions.establishSession(clientChannel, "none", "none", "test@msging.net", authentication, "test", (err, session) => {
var message: Lime.Message = <Lime.Message>{
id: "123",
to: "someone@test.net",
type: "text/plain",
content: "Hello, world!"
};
clientChannel.sendMessage(message);
});
};
transport.onClose = () => {
// transport closed callback
};
transport.onError = (err) => {
// transport error callback
};
transport.open("ws://test.net");
+200
View File
@@ -0,0 +1,200 @@
// Type definitions for lime-js 0.0.3
// Project: https://github.com/takenet/lime-js
// Definitions by: Arthur Xavier <https://github.com/arthur-xavier>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace Lime {
interface Envelope {
id?: string;
from?: string;
to?: string;
pp?: string;
metadata?: any;
}
interface Reason {
code: number;
description?: string;
}
interface Message extends Envelope {
type: string;
content: any;
}
interface Notification extends Envelope {
event: string;
reason?: Reason;
}
class NotificationEvent {
static accepted: string;
static validated: string;
static authorized: string;
static dispatched: string;
static received: string;
static consumed: string;
}
interface Command extends Envelope {
uri?: string;
type?: string;
resource?: any;
method: string;
status?: string;
reason?: Reason;
}
class CommandMethod {
static get: string;
static set: string;
static delete: string;
static observe: string;
static subscribe: string;
}
class CommandStatus {
static success: string;
static failure: string;
}
interface Session extends Envelope {
state: string;
encryptionOptions?: string[];
encryption?: string;
compressionOptions?: string[];
compression?: string;
scheme?: string;
authentication?: any;
reason?: Reason;
}
class SessionState {
static new: string;
static negotiating: string;
static authenticating: string;
static established: string;
static finishing: string;
static finished: string;
static failed: string;
}
class SessionEncryption {
static none: string;
static tls: string;
}
class SessionCompression {
static none: string;
static gzip: string;
}
class Authentication {
scheme: string;
static guest: string;
static plain: string;
static transport: string;
static key: string;
}
class GuestAuthentication extends Authentication {
scheme: string;
}
class TransportAuthentication extends Authentication {
scheme: string;
}
class PlainAuthentication extends Authentication {
scheme: string;
password: string;
}
class KeyAuthentication extends Authentication {
scheme: string;
key: string;
}
class Channel {
constructor(transport: Transport, autoReplyPings: boolean, autoNotifyReceipt: boolean);
sendMessage(message: Message): void;
onMessage(message: Message): void;
sendCommand(command: Command): void;
onCommand(command: Command): void;
sendNotification(notification: Notification): void;
onNotification(notification: Notification): void;
sendSession(session: Session): void;
onSession(session: Session): void;
transport: Transport;
remoteNode: string;
localNode: string;
sessionId: string;
state: string;
}
class ClientChannel extends Channel {
constructor(transport: Transport, autoReplyPings?: boolean, autoNotifyReceipt?: boolean);
startNewSession(): void;
negotiateSession(sessionCompression: string, sessionEncryption: string): void;
authenticateSession(identity: string, authentication: Authentication, instance: string): void;
sendFinishingSession(): void;
onSessionNegotiating(session: Session): void;
onSessionAuthenticating(session: Session): void;
onSessionEstablished(session: Session): void;
onSessionFinished(session: Session): void;
onSessionFailed(session: Session): void;
}
class ClientChannelExtensions {
static establishSession(clientChannel: ClientChannel, compression: string, encryption: string, identity: string, authentication: Authentication, instance: string, callback: (error: Error, session: Session) => any): void;
}
interface IMessageChannel {
sendMessage(message: Message): void;
onMessage: (message: Message) => any;
}
interface ICommandChannel {
sendCommand(command: Command): void;
onCommand: (command: Command) => any;
}
interface INotificationChannel {
sendNotification(notification: Notification): void;
onNotification: (notification: Notification) => any;
}
interface ISessionChannel {
sendSession(session: Session): void;
onSession: (session: Session) => any;
}
interface ISessionListener {
(session: Session): void;
}
interface Transport extends ITransportStateListener {
send(envelope: Envelope): void;
onEnvelope: (envelope: Envelope) => any;
open(uri: string): void;
close(): void;
getSupportedCompression(): string[];
setCompression(compression: string): void;
compression: string;
getSupportedEncryption(): string[];
setEncryption(encryption: string): void;
encryption: string;
}
interface ITransportEnvelopeListener {
(envelope: Envelope): void;
}
interface ITransportStateListener {
onOpen: () => void;
onClose: () => void;
onError: (error: string) => void;
}
class WebSocketTransport implements Transport {
webSocket: WebSocket;
constructor(traceEnabled?: boolean);
send(envelope: Envelope): void;
onEnvelope(envelope: Envelope): void;
open(uri: string): void;
close(): void;
getSupportedCompression(): string[];
setCompression(compression: string): void;
compression: string;
getSupportedEncryption(): string[];
setEncryption(encryption: string): void;
encryption: string;
onOpen(): void;
onClose(): void;
onError(error: string): void;
}
}
+522 -79
View File
@@ -1671,37 +1671,329 @@ module TestUnion {
}
}
result = <number[]>_.uniq([1, 2, 1, 3, 1]);
result = <number[]>_.uniq([1, 1, 2, 2, 3], true);
result = <string[]>_.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) {
return letter.toLowerCase();
});
result = <number[]>_.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math);
result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// _.uniq
module TestUniq {
type SampleObject = {a: number; b: string; c: boolean};
result = <number[]>_.unique([1, 2, 1, 3, 1]);
result = <number[]>_.unique([1, 1, 2, 2, 3], true);
result = <string[]>_.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) {
return letter.toLowerCase();
});
result = <number[]>_.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math);
result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
let array: SampleObject[];
let list: _.List<SampleObject>;
result = <number[]>_([1, 2, 1, 3, 1]).uniq().value();
result = <number[]>_([1, 1, 2, 2, 3]).uniq(true).value();
result = <string[]>_(['A', 'b', 'C', 'a', 'B', 'c']).uniq(function (letter) {
return letter.toLowerCase();
}).value();
result = <number[]>_([1, 2.5, 3, 1.5, 2, 3.5]).uniq(function (num) { return this.floor(num); }, Math).value();
result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).uniq('x').value();
let stringIterator: (value: string, index: number, collection: string) => string;
let listIterator: (value: SampleObject, index: number, collection: _.List<SampleObject>) => number;
result = <number[]>_([1, 2, 1, 3, 1]).unique().value();
result = <number[]>_([1, 1, 2, 2, 3]).unique(true).value();
result = <string[]>_(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) {
return letter.toLowerCase();
}).value();
result = <number[]>_([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value();
result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value();
{
let result: string[];
result = _.uniq<string>('abc');
result = _.uniq<string>('abc', true);
result = _.uniq<string>('abc', true, stringIterator);
result = _.uniq<string>('abc', true, stringIterator, any);
result = _.uniq<string, string>('abc', true, stringIterator);
result = _.uniq<string, string>('abc', true, stringIterator, any);
result = _.uniq<string>('abc', stringIterator);
result = _.uniq<string>('abc', stringIterator, any);
result = _.uniq<string, string>('abc', stringIterator);
result = _.uniq<string, string>('abc', stringIterator, any);
}
{
let result: SampleObject[];
result = _.uniq<SampleObject>(array);
result = _.uniq<SampleObject>(array, true);
result = _.uniq<SampleObject>(array, true, listIterator);
result = _.uniq<SampleObject>(array, true, listIterator, any);
result = _.uniq<SampleObject, number>(array, true, listIterator);
result = _.uniq<SampleObject, number>(array, true, listIterator, any);
result = _.uniq<SampleObject>(array, listIterator);
result = _.uniq<SampleObject>(array, listIterator, any);
result = _.uniq<SampleObject, number>(array, listIterator);
result = _.uniq<SampleObject, number>(array, listIterator, any);
result = _.uniq<SampleObject>(array, true, 'a');
result = _.uniq<SampleObject>(array, true, 'a', any);
result = _.uniq<SampleObject>(array, 'a');
result = _.uniq<SampleObject>(array, 'a', any);
result = _.uniq<SampleObject>(array, true, {a: 42});
result = _.uniq<{a: number}, SampleObject>(array, true, {a: 42});
result = _.uniq<SampleObject>(array, {a: 42});
result = _.uniq<{a: number}, SampleObject>(array, {a: 42});
result = _.uniq<SampleObject>(list);
result = _.uniq<SampleObject>(list, true);
result = _.uniq<SampleObject>(list, true, listIterator);
result = _.uniq<SampleObject>(list, true, listIterator, any);
result = _.uniq<SampleObject, number>(list, true, listIterator);
result = _.uniq<SampleObject, number>(list, true, listIterator, any);
result = _.uniq<SampleObject>(list, listIterator);
result = _.uniq<SampleObject>(list, listIterator, any);
result = _.uniq<SampleObject, number>(list, listIterator);
result = _.uniq<SampleObject, number>(list, listIterator, any);
result = _.uniq<SampleObject>(list, true, 'a');
result = _.uniq<SampleObject>(list, true, 'a', any);
result = _.uniq<SampleObject>(list, 'a');
result = _.uniq<SampleObject>(list, 'a', any);
result = _.uniq<SampleObject>(list, true, {a: 42});
result = _.uniq<{a: number}, SampleObject>(list, true, {a: 42});
result = _.uniq<SampleObject>(list, {a: 42});
result = _.uniq<{a: number}, SampleObject>(list, {a: 42});
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _('abc').uniq();
result = _('abc').uniq(true);
result = _('abc').uniq<string>(true, stringIterator);
result = _('abc').uniq<string>(true, stringIterator, any);
result = _('abc').uniq<string>(stringIterator);
result = _('abc').uniq<string>(stringIterator, any);
}
{
let result: _.LoDashImplicitArrayWrapper<SampleObject>;
result = _(array).uniq();
result = _(array).uniq(true);
result = _(array).uniq<number>(true, listIterator);
result = _(array).uniq<number>(true, listIterator, any);
result = _(array).uniq<number>(listIterator);
result = _(array).uniq<number>(listIterator, any);
result = _(array).uniq(true, 'a');
result = _(array).uniq(true, 'a', any);
result = _(array).uniq('a');
result = _(array).uniq('a', any);
result = _(array).uniq<{a: number}>(true, {a: 42});
result = _(array).uniq<{a: number}>({a: 42});
result = _(list).uniq<SampleObject>();
result = _(list).uniq<SampleObject>(true);
result = _(list).uniq<SampleObject>(true, listIterator);
result = _(list).uniq<SampleObject>(true, listIterator, any);
result = _(list).uniq<SampleObject, number>(true, listIterator);
result = _(list).uniq<SampleObject, number>(true, listIterator, any);
result = _(list).uniq<SampleObject>(listIterator);
result = _(list).uniq<SampleObject>(listIterator, any);
result = _(list).uniq<SampleObject, number>(listIterator);
result = _(list).uniq<SampleObject, number>(listIterator, any);
result = _(list).uniq<SampleObject>(true, 'a');
result = _(list).uniq<SampleObject>(true, 'a', any);
result = _(list).uniq<SampleObject>('a');
result = _(list).uniq<SampleObject>('a', any);
result = _(list).uniq<SampleObject>(true, {a: 42});
result = _(list).uniq<{a: number}, SampleObject>(true, {a: 42});
result = _(list).uniq<SampleObject>({a: 42});
result = _(list).uniq<{a: number}, SampleObject>({a: 42});
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _('abc').chain().uniq();
result = _('abc').chain().uniq(true);
result = _('abc').chain().uniq<string>(true, stringIterator);
result = _('abc').chain().uniq<string>(true, stringIterator, any);
result = _('abc').chain().uniq<string>(stringIterator);
result = _('abc').chain().uniq<string>(stringIterator, any);
}
{
let result: _.LoDashExplicitArrayWrapper<SampleObject>;
result = _(array).chain().uniq();
result = _(array).chain().uniq(true);
result = _(array).chain().uniq<number>(true, listIterator);
result = _(array).chain().uniq<number>(true, listIterator, any);
result = _(array).chain().uniq<number>(listIterator);
result = _(array).chain().uniq<number>(listIterator, any);
result = _(array).chain().uniq(true, 'a');
result = _(array).chain().uniq(true, 'a', any);
result = _(array).chain().uniq('a');
result = _(array).chain().uniq('a', any);
result = _(array).chain().uniq<{a: number}>(true, {a: 42});
result = _(array).chain().uniq<{a: number}>({a: 42});
result = _(list).chain().uniq<SampleObject>();
result = _(list).chain().uniq<SampleObject>(true);
result = _(list).chain().uniq<SampleObject>(true, listIterator);
result = _(list).chain().uniq<SampleObject>(true, listIterator, any);
result = _(list).chain().uniq<SampleObject, number>(true, listIterator);
result = _(list).chain().uniq<SampleObject, number>(true, listIterator, any);
result = _(list).chain().uniq<SampleObject>(listIterator);
result = _(list).chain().uniq<SampleObject>(listIterator, any);
result = _(list).chain().uniq<SampleObject, number>(listIterator);
result = _(list).chain().uniq<SampleObject, number>(listIterator, any);
result = _(list).chain().uniq<SampleObject>(true, 'a');
result = _(list).chain().uniq<SampleObject>(true, 'a', any);
result = _(list).chain().uniq<SampleObject>('a');
result = _(list).chain().uniq<SampleObject>('a', any);
result = _(list).chain().uniq<SampleObject>(true, {a: 42});
result = _(list).chain().uniq<{a: number}, SampleObject>(true, {a: 42});
result = _(list).chain().uniq<SampleObject>({a: 42});
result = _(list).chain().uniq<{a: number}, SampleObject>({a: 42});
}
}
// _.unique
module TestUnique {
type SampleObject = {a: number; b: string; c: boolean};
let array: SampleObject[];
let list: _.List<SampleObject>;
let stringIterator: (value: string, index: number, collection: string) => string;
let listIterator: (value: SampleObject, index: number, collection: _.List<SampleObject>) => number;
{
let result: string[];
result = _.unique<string>('abc');
result = _.unique<string>('abc', true);
result = _.unique<string>('abc', true, stringIterator);
result = _.unique<string>('abc', true, stringIterator, any);
result = _.unique<string, string>('abc', true, stringIterator);
result = _.unique<string, string>('abc', true, stringIterator, any);
result = _.unique<string>('abc', stringIterator);
result = _.unique<string>('abc', stringIterator, any);
result = _.unique<string, string>('abc', stringIterator);
result = _.unique<string, string>('abc', stringIterator, any);
}
{
let result: SampleObject[];
result = _.unique<SampleObject>(array);
result = _.unique<SampleObject>(array, true);
result = _.unique<SampleObject>(array, true, listIterator);
result = _.unique<SampleObject>(array, true, listIterator, any);
result = _.unique<SampleObject, number>(array, true, listIterator);
result = _.unique<SampleObject, number>(array, true, listIterator, any);
result = _.unique<SampleObject>(array, listIterator);
result = _.unique<SampleObject>(array, listIterator, any);
result = _.unique<SampleObject, number>(array, listIterator);
result = _.unique<SampleObject, number>(array, listIterator, any);
result = _.unique<SampleObject>(array, true, 'a');
result = _.unique<SampleObject>(array, true, 'a', any);
result = _.unique<SampleObject>(array, 'a');
result = _.unique<SampleObject>(array, 'a', any);
result = _.unique<SampleObject>(array, true, {a: 42});
result = _.unique<{a: number}, SampleObject>(array, true, {a: 42});
result = _.unique<SampleObject>(array, {a: 42});
result = _.unique<{a: number}, SampleObject>(array, {a: 42});
result = _.unique<SampleObject>(list);
result = _.unique<SampleObject>(list, true);
result = _.unique<SampleObject>(list, true, listIterator);
result = _.unique<SampleObject>(list, true, listIterator, any);
result = _.unique<SampleObject, number>(list, true, listIterator);
result = _.unique<SampleObject, number>(list, true, listIterator, any);
result = _.unique<SampleObject>(list, listIterator);
result = _.unique<SampleObject>(list, listIterator, any);
result = _.unique<SampleObject, number>(list, listIterator);
result = _.unique<SampleObject, number>(list, listIterator, any);
result = _.unique<SampleObject>(list, true, 'a');
result = _.unique<SampleObject>(list, true, 'a', any);
result = _.unique<SampleObject>(list, 'a');
result = _.unique<SampleObject>(list, 'a', any);
result = _.unique<SampleObject>(list, true, {a: 42});
result = _.unique<{a: number}, SampleObject>(list, true, {a: 42});
result = _.unique<SampleObject>(list, {a: 42});
result = _.unique<{a: number}, SampleObject>(list, {a: 42});
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _('abc').unique();
result = _('abc').unique(true);
result = _('abc').unique<string>(true, stringIterator);
result = _('abc').unique<string>(true, stringIterator, any);
result = _('abc').unique<string>(stringIterator);
result = _('abc').unique<string>(stringIterator, any);
}
{
let result: _.LoDashImplicitArrayWrapper<SampleObject>;
result = _(array).unique();
result = _(array).unique(true);
result = _(array).unique<number>(true, listIterator);
result = _(array).unique<number>(true, listIterator, any);
result = _(array).unique<number>(listIterator);
result = _(array).unique<number>(listIterator, any);
result = _(array).unique(true, 'a');
result = _(array).unique(true, 'a', any);
result = _(array).unique('a');
result = _(array).unique('a', any);
result = _(array).unique<{a: number}>(true, {a: 42});
result = _(array).unique<{a: number}>({a: 42});
result = _(list).unique<SampleObject>();
result = _(list).unique<SampleObject>(true);
result = _(list).unique<SampleObject>(true, listIterator);
result = _(list).unique<SampleObject>(true, listIterator, any);
result = _(list).unique<SampleObject, number>(true, listIterator);
result = _(list).unique<SampleObject, number>(true, listIterator, any);
result = _(list).unique<SampleObject>(listIterator);
result = _(list).unique<SampleObject>(listIterator, any);
result = _(list).unique<SampleObject, number>(listIterator);
result = _(list).unique<SampleObject, number>(listIterator, any);
result = _(list).unique<SampleObject>(true, 'a');
result = _(list).unique<SampleObject>(true, 'a', any);
result = _(list).unique<SampleObject>('a');
result = _(list).unique<SampleObject>('a', any);
result = _(list).unique<SampleObject>(true, {a: 42});
result = _(list).unique<{a: number}, SampleObject>(true, {a: 42});
result = _(list).unique<SampleObject>({a: 42});
result = _(list).unique<{a: number}, SampleObject>({a: 42});
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _('abc').chain().unique();
result = _('abc').chain().unique(true);
result = _('abc').chain().unique<string>(true, stringIterator);
result = _('abc').chain().unique<string>(true, stringIterator, any);
result = _('abc').chain().unique<string>(stringIterator);
result = _('abc').chain().unique<string>(stringIterator, any);
}
{
let result: _.LoDashExplicitArrayWrapper<SampleObject>;
result = _(array).chain().unique();
result = _(array).chain().unique(true);
result = _(array).chain().unique<number>(true, listIterator);
result = _(array).chain().unique<number>(true, listIterator, any);
result = _(array).chain().unique<number>(listIterator);
result = _(array).chain().unique<number>(listIterator, any);
result = _(array).chain().unique(true, 'a');
result = _(array).chain().unique(true, 'a', any);
result = _(array).chain().unique('a');
result = _(array).chain().unique('a', any);
result = _(array).chain().unique<{a: number}>(true, {a: 42});
result = _(array).chain().unique<{a: number}>({a: 42});
result = _(list).chain().unique<SampleObject>();
result = _(list).chain().unique<SampleObject>(true);
result = _(list).chain().unique<SampleObject>(true, listIterator);
result = _(list).chain().unique<SampleObject>(true, listIterator, any);
result = _(list).chain().unique<SampleObject, number>(true, listIterator);
result = _(list).chain().unique<SampleObject, number>(true, listIterator, any);
result = _(list).chain().unique<SampleObject>(listIterator);
result = _(list).chain().unique<SampleObject>(listIterator, any);
result = _(list).chain().unique<SampleObject, number>(listIterator);
result = _(list).chain().unique<SampleObject, number>(listIterator, any);
result = _(list).chain().unique<SampleObject>(true, 'a');
result = _(list).chain().unique<SampleObject>(true, 'a', any);
result = _(list).chain().unique<SampleObject>('a');
result = _(list).chain().unique<SampleObject>('a', any);
result = _(list).chain().unique<SampleObject>(true, {a: 42});
result = _(list).chain().unique<{a: number}, SampleObject>(true, {a: 42});
result = _(list).chain().unique<SampleObject>({a: 42});
result = _(list).chain().unique<{a: number}, SampleObject>({a: 42});
}
}
// _.upzip
module TestUnzip {
@@ -2694,9 +2986,11 @@ module TestAny {
let array: TResult[];
let list: _.List<TResult>;
let dictionary: _.Dictionary<TResult>;
let numericDictionary: _.NumericDictionary<TResult>;
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => boolean;
let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary<TResult>) => boolean;
{
let result: boolean;
@@ -2719,6 +3013,12 @@ module TestAny {
result = _.any<TResult>(dictionary, '');
result = _.any<{a: number}, TResult>(dictionary, {a: 42});
result = _.any<TResult>(numericDictionary);
result = _.any<TResult>(numericDictionary, numericDictionaryIterator);
result = _.any<TResult>(numericDictionary, numericDictionaryIterator, any);
result = _.any<TResult>(numericDictionary, '');
result = _.any<{a: number}, TResult>(numericDictionary, {a: 42});
result = _(array).any();
result = _(array).any(listIterator);
result = _(array).any(listIterator, any);
@@ -2736,6 +3036,12 @@ module TestAny {
result = _(dictionary).any<TResult>(dictionaryIterator, any);
result = _(dictionary).any('');
result = _(dictionary).any<{a: number}>({a: 42});
result = _(numericDictionary).any<TResult>();
result = _(numericDictionary).any<TResult>(numericDictionaryIterator);
result = _(numericDictionary).any<TResult>(numericDictionaryIterator, any);
result = _(numericDictionary).any('');
result = _(numericDictionary).any<{a: number}>({a: 42});
}
{
@@ -2758,6 +3064,12 @@ module TestAny {
result = _(dictionary).chain().any<TResult>(dictionaryIterator, any);
result = _(dictionary).chain().any('');
result = _(dictionary).chain().any<{a: number}>({a: 42});
result = _(numericDictionary).chain().any<TResult>();
result = _(numericDictionary).chain().any<TResult>(numericDictionaryIterator);
result = _(numericDictionary).chain().any<TResult>(numericDictionaryIterator, any);
result = _(numericDictionary).chain().any('');
result = _(numericDictionary).chain().any<{a: number}>({a: 42});
}
}
@@ -4378,9 +4690,11 @@ module TestSome {
let array: TResult[];
let list: _.List<TResult>;
let dictionary: _.Dictionary<TResult>;
let numericDictionary: _.NumericDictionary<TResult>;
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => boolean;
let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary<TResult>) => boolean;
{
let result: boolean;
@@ -4403,6 +4717,12 @@ module TestSome {
result = _.some<TResult>(dictionary, '');
result = _.some<{a: number}, TResult>(dictionary, {a: 42});
result = _.some<TResult>(numericDictionary);
result = _.some<TResult>(numericDictionary, numericDictionaryIterator);
result = _.some<TResult>(numericDictionary, numericDictionaryIterator, any);
result = _.some<TResult>(numericDictionary, '');
result = _.some<{a: number}, TResult>(numericDictionary, {a: 42});
result = _(array).some();
result = _(array).some(listIterator);
result = _(array).some(listIterator, any);
@@ -4420,6 +4740,12 @@ module TestSome {
result = _(dictionary).some<TResult>(dictionaryIterator, any);
result = _(dictionary).some('');
result = _(dictionary).some<{a: number}>({a: 42});
result = _(numericDictionary).some<TResult>();
result = _(numericDictionary).some<TResult>(numericDictionaryIterator);
result = _(numericDictionary).some<TResult>(numericDictionaryIterator, any);
result = _(numericDictionary).some('');
result = _(numericDictionary).some<{a: number}>({a: 42});
}
{
@@ -4442,6 +4768,12 @@ module TestSome {
result = _(dictionary).chain().some<TResult>(dictionaryIterator, any);
result = _(dictionary).chain().some('');
result = _(dictionary).chain().some<{a: number}>({a: 42});
result = _(numericDictionary).chain().some<TResult>();
result = _(numericDictionary).chain().some<TResult>(numericDictionaryIterator);
result = _(numericDictionary).chain().some<TResult>(numericDictionaryIterator, any);
result = _(numericDictionary).chain().some('');
result = _(numericDictionary).chain().some<{a: number}>({a: 42});
}
}
@@ -4695,16 +5027,43 @@ var addTwoNumbers = function (x: number, y: number) { return x + y };
var plusTwo = _.bind(addTwoNumbers, null, 2);
plusTwo(100);
var view = {
'label': 'docs',
'onClick': function () { console.log('clicked ' + this.label); }
};
// _.bindAll
module TestBindAll {
interface SampleObject {
a: Function;
b: Function;
c: Function;
}
view = _.bindAll(view);
jQuery('#docs').on('click', view.onClick);
let object: SampleObject;
view = _(view).bindAll().value();
jQuery('#docs').on('click', view.onClick);
{
let result: SampleObject;
result = _.bindAll<SampleObject>(object);
result = _.bindAll<SampleObject>(object, 'c');
result = _.bindAll<SampleObject>(object, ['b'], 'c');
result = _.bindAll<SampleObject>(object, 'a', ['b'], 'c');
}
{
let result: _.LoDashImplicitObjectWrapper<SampleObject>;
result = _(object).bindAll();
result = _(object).bindAll('c');
result = _(object).bindAll(['b'], 'c');
result = _(object).bindAll('a', ['b'], 'c');
}
{
let result: _.LoDashExplicitObjectWrapper<SampleObject>;
result = _(object).chain().bindAll();
result = _(object).chain().bindAll('c');
result = _(object).chain().bindAll(['b'], 'c');
result = _(object).chain().bindAll('a', ['b'], 'c');
}
}
var objectBindKey = {
'name': 'moe',
@@ -5395,21 +5754,39 @@ result = <boolean>_({}).isArguments();
}
// _.isArray
result = <boolean>_.isArray(any);
result = <boolean>_(1).isArray();
result = <boolean>_<any>([]).isArray();
result = <boolean>_({}).isArray();
{
let value: number[]|string = [1, 3, 5];
if (_.isArray(value)) {
let length: number[] = value.concat(4);
// compile error
// let char: string = value.charAt(0);
} else {
let char: string = value.charAt(0);
// compile error
// let length: number[] = value.concat(4);
}
module TestIsArray {
{
let value: number|string[]|boolean[];
if (_.isArray<string>(value)) {
let result: string[] = value;
}
else {
if (_.isArray<boolean>(value)) {
let result: boolean[] = value;
}
else {
let result: number = value;
}
}
}
{
let result: boolean;
result = _.isArray(any);
result = _(1).isArray();
result = _<any>([]).isArray();
result = _({}).isArray();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isArray();
result = _<any>([]).chain().isArray();
result = _({}).chain().isArray();
}
}
// _.isBoolean
@@ -5610,15 +5987,35 @@ module TestIsNaN {
}
// _.isNative
result = <boolean>_.isNative(Array.prototype.push);
result = <boolean>_(Array.prototype.push).isNative();
{
let value: Function|string = "foo";
if (_.isNative(value)) {
value();
} else {
let result: string = value;
}
module TestIsNull {
{
let value: number|Function;
if (_.isNative(value)) {
let result: Function = value;
}
else {
let result: number = value;
}
}
{
let result: boolean;
result = _.isNative(any);
result = _(1).isNative();
result = _<any>([]).isNative();
result = _({}).isNative();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isNative();
result = _<any>([]).chain().isNative();
result = _({}).chain().isNative();
}
}
// _.isNull
@@ -5657,10 +6054,24 @@ result = <boolean>_({}).isNumber();
}
// _.isObject
result = <boolean>_.isObject(any);
result = <boolean>_(1).isObject();
result = <boolean>_<any>([]).isObject();
result = <boolean>_({}).isObject();
module TestIsObject {
{
let result: boolean;
result = _.isObject(any);
result = _(1).isObject();
result = _<any>([]).isObject();
result = _({}).isObject();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isObject();
result = _<any>([]).chain().isObject();
result = _({}).chain().isObject();
}
}
// _.isPlainObject
result = <boolean>_.isPlainObject(any);
@@ -5700,17 +6111,34 @@ module TestIsRegExp {
}
// _.isString
result = <boolean>_.isString(any);
result = <boolean>_(1).isString();
result = <boolean>_<any>([]).isString();
result = <boolean>_({}).isString();
{
let value: string|number = "foo";
if (_.isString(value)) {
let result: string = value;
} else {
let result: number = value * 42;
}
module TestIsString {
{
let value: number|string;
if (_.isString(value)) {
let result: string = value;
}
else {
let result: number = value;
}
}
{
let result: boolean;
result = _.isString(any);
result = _(1).isString();
result = _<any>([]).isString();
result = _({}).isString();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isString();
result = _<any>([]).chain().isString();
result = _({}).chain().isString();
}
}
// _.isTypedArray
@@ -5730,10 +6158,25 @@ module TestIsTypedArray {
}
// _.isUndefined
result = <boolean>_.isUndefined(any);
result = <boolean>_(1).isUndefined();
result = <boolean>_<any>([]).isUndefined();
result = <boolean>_({}).isUndefined();
module TestIsUndefined {
{
let result: boolean;
result = _.isUndefined(any);
result = _(1).isUndefined();
result = _<any>([]).isUndefined();
result = _({}).isUndefined();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(1).chain().isUndefined();
result = _<any>([]).chain().isUndefined();
result = _({}).chain().isUndefined();
}
}
// _.lt
module TestLt {
+845 -301
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -78,9 +78,11 @@ declare module 'mailparser' {
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
setMaxListeners(n: number): EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
}
}
+10 -5
View File
@@ -49,8 +49,8 @@ function test() {
function testKit() {
makerjs.kit.construct(null, null);
makerjs.kit.getParameterValues(null);
(<MakerJs.kit.IMetaParameter>{}).max;
(<MakerJs.kit.IKit>{}).metaParameters;
(<MakerJs.IMetaParameter>{}).max;
(<MakerJs.IKit>{}).metaParameters;
}
function testMeasure() {
@@ -66,11 +66,14 @@ function test() {
}
function testModel(){
makerjs.model.combine(model, model, true, false, true, false);
makerjs.model.breakPathsAtIntersections(model, { paths:{ } });
var opts: MakerJs.ICombineOptions = { trimDeadEnds: true, pointMatchingDistance: 2 };
makerjs.model.combine(model, model, true, false, true, false, opts);
makerjs.model.convertUnits(model, makerjs.unitType.Centimeter);
makerjs.model.countChildModels(model);
makerjs.model.detachLoop(model);
makerjs.model.findLoops(model);
makerjs.model.getSimilarModelId(model, 'foo');
makerjs.model.getSimilarPathId(model, 'foo');
makerjs.model.isPathInsideModel(paths.line, model);
makerjs.model.mirror(model, false, true);
@@ -89,19 +92,20 @@ function test() {
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.OvalArc(6, 4, 2, 12, true),
new makerjs.models.Polygon(7, 5),
new makerjs.models.Rectangle(8, 9),
new makerjs.models.Ring(7, 7),
new makerjs.models.RoundRectangle(2, 2, 0),
new makerjs.models.SCurve(5, .9),
new makerjs.models.Slot([0, 0], [1, 1], 7),
new makerjs.models.Square(8),
new makerjs.models.Star(5, 10, 5)
];
}
function testPath() {
makerjs.path.areEqual(paths.line, paths.circle);
makerjs.path.areEqual(paths.line, paths.circle, 4);
makerjs.path.breakAtPoint(paths.arc, [0,0]).type;
makerjs.path.dogbone(paths.line, paths.line, 7);
makerjs.path.fillet(paths.arc, paths.line, 4);
@@ -140,6 +144,7 @@ function test() {
makerjs.point.add(p1, p2);
makerjs.point.areEqual(p1, p2);
makerjs.point.areEqualRounded(p1, p2);
makerjs.point.average(p1, p2);
makerjs.point.clone(p1);
makerjs.point.closest([0,0], [p1, p2]);
makerjs.point.fromAngleOnCircle(22, paths.circle);
+126 -53
View File
@@ -252,9 +252,22 @@ declare module MakerJs {
*/
interface IPointMatchOptions {
/**
* Optional exemplar of number of decimal places.
* Max distance to consider two points as the same.
*/
accuracy?: number;
pointMatchingDistance?: number;
}
/**
* Options to pass to model.combine.
*/
interface ICombineOptions extends IPointMatchOptions {
/**
* Flag to remove paths which are not part of a loop.
*/
trimDeadEnds?: boolean;
/**
* Point which is known to be outside of the model.
*/
farPoint?: IPoint;
}
/**
* Options to pass to model.findLoops.
@@ -343,6 +356,63 @@ declare module MakerJs {
* Test to see if an object implements the required properties of a model.
*/
function isModel(item: any): boolean;
/**
* Reference to a path id within a model.
*/
interface IRefPathIdInModel {
modelContext: IModel;
pathId: string;
}
/**
* Path and its reference id within a model
*/
interface IRefPathInModel extends IRefPathIdInModel {
pathContext: IPath;
}
/**
* Describes a parameter and its limits.
*/
interface IMetaParameter {
/**
* Display text of the parameter.
*/
title: string;
/**
* Type of the parameter. Currently supports "range".
*/
type: string;
/**
* Optional minimum value of the range.
*/
min?: number;
/**
* Optional maximum value of the range.
*/
max?: number;
/**
* Optional step value between min and max.
*/
step?: number;
/**
* Initial sample value for this parameter.
*/
value: any;
}
/**
* An IKit is a model-producing class with some sample parameters. Think of it as a packaged model with instructions on how to best use it.
*/
interface IKit {
/**
* The constructor. The kit must be "new-able" and it must produce an IModel.
* It can have any number of any type of parameters.
*/
new (...args: any[]): IModel;
/**
* Attached to the constructor is a property named metaParameters which is an array of IMetaParameter objects.
* Each element of the array corresponds to a parameter of the constructor, in order.
*/
metaParameters?: IMetaParameter[];
}
}
declare module MakerJs.angle {
/**
@@ -352,7 +422,7 @@ declare module MakerJs.angle {
* @param b Second angle.
* @returns true if angles are the same, false if they are not
*/
function areEqual(angle1: number, angle2: number): boolean;
function areEqual(angle1: number, angle2: number, accuracy?: number): boolean;
/**
* Ensures an angle is not greater than 360
*
@@ -439,7 +509,7 @@ declare module MakerJs.point {
* @param b Second point.
* @returns true if points are the same, false if they are not
*/
function areEqual(a: IPoint, b: IPoint): boolean;
function areEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean;
/**
* Find out if two points are equal after rounding.
*
@@ -449,6 +519,14 @@ declare module MakerJs.point {
* @returns true if points are the same, false if they are not
*/
function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean;
/**
* Get the average of two points.
*
* @param a First point.
* @param b Second point.
* @returns New point object which is the average of a and b.
*/
function average(a: IPoint, b: IPoint): IPoint;
/**
* Clone a point into a new point.
*
@@ -567,7 +645,7 @@ declare module MakerJs.path {
* @param b Second path.
* @returns true if paths are the same, false if they are not
*/
function areEqual(path1: IPath, path2: IPath): boolean;
function areEqual(path1: IPath, path2: IPath, withinPointDistance?: number): boolean;
/**
* Create a clone of a path, mirrored on either or both x and y axes.
*
@@ -698,11 +776,18 @@ declare module MakerJs.model {
* @returns Number of child models.
*/
function countChildModels(modelContext: IModel): number;
/**
* Get an unused id in the models map with the same prefix.
*
* @param modelContext The model containing the models map.
* @param modelId The id to use directly (if unused), or as a prefix.
*/
function getSimilarModelId(modelContext: IModel, modelId: string): string;
/**
* Get an unused id in the paths map with the same prefix.
*
* @param modelContext The model containing the paths map.
* @param pathId The pathId to use directly (if unused), or as a prefix.
* @param pathId The id to use directly (if unused), or as a prefix.
*/
function getSimilarPathId(modelContext: IModel, pathId: string): string;
/**
@@ -782,7 +867,14 @@ declare module MakerJs.model {
*/
function isPathInsideModel(pathContext: IPath, modelContext: IModel, farPoint?: IPoint): boolean;
/**
* Combine 2 models. The models should be originated.
* Break a model's paths everywhere they intersect with another path.
*
* @param modelToBreak The model containing paths to be broken.
* @param modelToIntersect Optional model containing paths to look for intersection, or else the modelToBreak will be used.
*/
function breakPathsAtIntersections(modelToBreak: IModel, modelToIntersect?: IModel): void;
/**
* Combine 2 models. The models should be originated, and every path within each model should be part of a loop.
*
* @param modelA First model to combine.
* @param modelB Second model to combine.
@@ -793,7 +885,7 @@ declare module MakerJs.model {
* @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, keepDuplicates?: boolean, farPoint?: IPoint): void;
function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): void;
}
declare module MakerJs.units {
/**
@@ -1003,50 +1095,6 @@ declare module MakerJs.path {
function fillet(path1: IPath, path2: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc;
}
declare module MakerJs.kit {
/**
* Describes a parameter and its limits.
*/
interface IMetaParameter {
/**
* Display text of the parameter.
*/
title: string;
/**
* Type of the parameter. Currently supports "range".
*/
type: string;
/**
* Optional minimum value of the range.
*/
min?: number;
/**
* Optional maximum value of the range.
*/
max?: number;
/**
* Optional step value between min and max.
*/
step?: number;
/**
* Initial sample value for this parameter.
*/
value: any;
}
/**
* An IKit is a model-producing class with some sample parameters. Think of it as a packaged model with instructions on how to best use it.
*/
interface IKit {
/**
* The constructor. The kit must be "new-able" and it must produce an IModel.
* It can have any number of any type of parameters.
*/
new (...args: any[]): IModel;
/**
* Attached to the constructor is a property named metaParameters which is an array of IMetaParameter objects.
* Each element of the array corresponds to a parameter of the constructor, in order.
*/
metaParameters?: IMetaParameter[];
}
/**
* Helper function to use the JavaScript "apply" function in conjunction with the "new" keyword.
*
@@ -1064,6 +1112,23 @@ declare module MakerJs.kit {
function getParameterValues(ctor: IKit): any[];
}
declare module MakerJs.model {
/**
* @private
*/
interface IPointMappedItem<T> {
averagePoint: IPoint;
item: T;
}
/**
* @private
*/
class PointMap<T> {
matchingDistance: number;
list: IPointMappedItem<T>[];
constructor(matchingDistance?: number);
add(pointToAdd: IPoint, item: T): void;
find(pointToFind: IPoint, saveAverage: boolean): T;
}
/**
* Find paths that have common endpoints and form loops.
*
@@ -1078,6 +1143,7 @@ declare module MakerJs.model {
* @param loopToDetach The model to search for loops.
*/
function detachLoop(loopToDetach: IModel): void;
function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number): void;
}
declare module MakerJs.exporter {
/**
@@ -1247,7 +1313,7 @@ declare module MakerJs.models {
declare module MakerJs.models {
class OvalArc implements IModel {
paths: IPathMap;
constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number);
constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean);
}
}
declare module MakerJs.models {
@@ -1267,6 +1333,13 @@ declare module MakerJs.models {
constructor(width: number, height: number);
}
}
declare module MakerJs.models {
class Slot implements IModel {
paths: IPathMap;
origin: IPoint;
constructor(origin: IPoint, endPoint: IPoint, radius: number);
}
}
declare module MakerJs.models {
class Square extends Rectangle {
constructor(side: number);
+12 -8
View File
@@ -123,6 +123,7 @@ declare namespace __MaterialUI {
}
interface AppCanvasProps extends React.Props<AppCanvas> {
style?: React.CSSProperties;
}
export class AppCanvas extends React.Component<AppCanvasProps, {}> {
}
@@ -319,7 +320,7 @@ declare namespace __MaterialUI {
interface DatePickerProps extends React.Props<DatePicker> {
autoOk?: boolean;
defaultDate?: Date;
formatDate?: string;
formatDate?: (date:Date) => string;
hintText?: string;
floatingLabelText?: string;
hideToolbarYearChange?: boolean;
@@ -787,6 +788,7 @@ declare namespace __MaterialUI {
menuItemStyle?: React.CSSProperties;
selectedIndex?: number;
underlineStyle?: React.CSSProperties;
underlineFocusStyle?: React.CSSProperties;
iconStyle?: React.CSSProperties;
labelStyle?: React.CSSProperties;
style?: React.CSSProperties;
@@ -1140,7 +1142,7 @@ declare namespace __MaterialUI {
namespace Tabs {
interface TabProps extends React.Props<Tab> {
label?: string;
label?: any;
value?: string;
selected?: boolean;
width?: string;
@@ -1257,7 +1259,9 @@ declare namespace __MaterialUI {
interface TableRowColumnProps extends React.Props<TableRowColumn> {
columnNumber?: number;
colSpan?: number;
hoverable?: boolean;
onClick?: React.MouseEventHandler;
onHover?: (e: React.MouseEvent, column: number) => void;
onHoverExit?: (e: React.MouseEvent, column: number) => void;
style?: React.CSSProperties;
@@ -1532,19 +1536,19 @@ declare namespace __MaterialUI {
export class MenuDivider extends React.Component<MenuDividerProps, {}>{
}
}
namespace GridList {
interface GridListProps extends React.Props<GridList> {
cols?: number;
padding?: number;
cellHeight?: number;
style?: React.CSSProperties;
}
export class GridList extends React.Component<GridListProps, {}>{
}
interface GridTileProps extends React.Props<GridTile> {
title?: string;
subtitle?: __React.ReactNode;
@@ -1557,10 +1561,10 @@ declare namespace __MaterialUI {
rootClass?: string | __React.Component<any,any>;
style?: React.CSSProperties;
}
export class GridTile extends React.Component<GridTileProps, {}>{
}
}
} // __MaterialUI
+38 -2
View File
@@ -3,6 +3,10 @@
import sql = require('mssql');
interface Entity{
value: number;
}
var config: sql.config = {
user: 'user',
password: 'password',
@@ -33,6 +37,18 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
}
});
getArticlesQuery = "SELECT 1 as value FROM TABLE";
requestQuery.query<Entity>(getArticlesQuery, function (err, recordSet) {
if (err) {
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
// checking to see if the articles returned as at least one.
else if (recordSet.length > 0 && recordSet[0].value) {
}
});
var requestStoredProcedure = new sql.Request(connection);
var testId: number = 0;
var testString: string = 'test';
@@ -50,6 +66,15 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
}
});
requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
if (err != null) {
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
else {
console.info(returnValue);
}
});
var requestStoredProcedureWithOutput = new sql.Request(connection);
var testId: number = 0;
var testString: string = 'test';
@@ -74,6 +99,15 @@ var connection: sql.Connection = new sql.Connection(config, function (err: any)
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
}
});
requestStoredProcedure.execute<Entity>('StoredProcedureName', function (err, recordsets, returnValue) {
if (err != null) {
console.error('Error happened calling Query: ' + err.name + " " + err.message);
}
else {
console.info(requestStoredProcedureWithOutput.parameters['output'].value);
}
});
}
});
@@ -109,8 +143,10 @@ function test_promise_returns() {
var request = new sql.Request();
request.batch('create procedure #temporary as select * from table').then((recordset) => { });
request.batch<Entity>('create procedure #temporary as select * from table;select 1 as value').then((recordset) => { });
request.bulk(new sql.Table("table_name")).then(() => { });
request.query('SELECT 1').then((recordset) => { });
request.query<Entity>('SELECT 1 as value').then(res => { });
request.execute('procedure_name').then((recordset) => { });
}
@@ -120,7 +156,7 @@ function test_request_constructor() {
var connection: sql.Connection = new sql.Connection(config);
var preparedStatment = new sql.PreparedStatement(connection);
var transaction = new sql.Transaction(connection);
var request1 = new sql.Request(connection);
var request2 = new sql.Request(preparedStatment);
var request3 = new sql.Request(transaction);
@@ -141,4 +177,4 @@ function test_classes_extend_eventemitter() {
request.on('error', () => { });
preparedStatment.on('error', () => { })
}
}
+8 -2
View File
@@ -7,7 +7,7 @@
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "mssql" {
import events = require('events');
import events = require('events');
type sqlTypeWithNoParams = { type: sqlTypeFactoryWithNoParams }
type sqlTypeWithLength = { type: sqlTypeFactoryWithLength, length: number }
@@ -200,15 +200,19 @@ declare module "mssql" {
public constructor(transaction: Transaction);
public constructor(preparedStatement: PreparedStatement);
public execute(procedure: string): Promise<recordSet>;
public execute(procedure: string, callback: (err?: any, recordsets?: any, returnValue?: any) => void): void;
public execute<Entity>(procedure: string, callback: (err?: any, recordsets?: Entity[], returnValue?: any) => void): void;
public input(name: string, value: any): void;
public input(name: string, type: any, value: any): void;
public output(name: string, type: any, value?: any): void;
public pipe(stream: NodeJS.WritableStream): void;
public query(command: string): Promise<void>;
public query<Entity>(command: string): Promise<Entity[]>;
public query(command: string, callback: (err?: any, recordset?: any) => void): void;
public query<Entity>(command: string, callback: (err?: any, recordset?: Entity[]) => void): void;
public batch(batch: string): Promise<recordSet>;
public batch<Entity>(batch: string): Promise<Entity[]>;
public batch(batch: string, callback: (err?: any, recordset?: any) => void): void;
public batch<Entity>(batch: string, callback: (err?: any, recordset?: Entity[]) => void): void;
public bulk(table: Table): Promise<void>;
public bulk(table: Table, callback: (err: any, rowCount: any) => void): void;
public cancel(): void;
@@ -254,7 +258,9 @@ declare module "mssql" {
public prepare(statement?: string): Promise<void>;
public prepare(statement?: string, callback?: (err?: any) => void): void;
public execute(values: Object): Promise<recordSet>;
public execute<Entity>(values: Object): Promise<Entity[]>;
public execute(values: Object, callback: (err: any, recordSet: recordSet) => void): void;
public execute<Entity>(values: Object, callback: (err: any, recordSet: Entity[]) => void): void;
public unprepare(): Promise<void>;
public unprepare(callback: (err?: any) => void): void;
}
+20
View File
@@ -0,0 +1,20 @@
/// <reference path="ngwysiwyg.d.ts" />
//import ngWYSIWYG = require("ngWYSIWYG");
var complete: ngWYSIWYG.Config = {
sanitize: false,
toolbar: [
{ name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] },
{ name: "paragraph", items: ["orderedList", "unorderedList", "outdent", "indent", "-"] },
{ name: "doers", items: ["removeFormatting", "undo", "redo", "-"] },
{ name: "colors", items: ["fontColor", "backgroundColor", "-"] },
{ name: "links", items: ["image", "hr", "symbols", "link", "unlink", "-"] },
{ name: "tools", items: ["print", "-"] },
{ name: "styling", items: ["font", "size", "format"] },
]
};
var partial: ngWYSIWYG.Config = {
sanitize: false
};
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for Marked
// Project: https://github.com/psergus/ngWYSIWYG
// Definitions by: Patrick Mac Kay <https://github.com/patrick-mackay>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module ngWYSIWYG {
export interface Toolbar {
name: string;
items: string[];
}
export interface Config {
sanitize: boolean;
toolbar?: Toolbar[];
}
}
+90
View File
@@ -0,0 +1,90 @@
/// <reference path="node-dir.d.ts" />
import * as dir from "node-dir";
// display contents of files in this script's directory
dir.readFiles("./",
function(err, content, next) {
console.log('content:', content);
next();
},
function(err, files) {
console.log('finished reading files:', files);
});
// display contents of huge files in this script's directory
dir.readFilesStream("./",
function(err: any, stream: any, next: any) {
var content = '';
stream.on('data', function(buffer: any) {
content += buffer.toString();
});
stream.on('end',function() {
console.log('content:', content);
next();
});
},
function(err, files) {
console.log('finished reading files:', files);
});
// match only filenames with a .txt extension and that don't start with a `.´
dir.readFiles("./", {
match: /.txt$/,
exclude: /^\./
}, function(err, content, next) {
console.log('content:', content);
next();
},
function(err, files){
console.log('finished reading files:',files);
});
// exclude an array of subdirectory names
dir.readFiles("./", {
exclude: ['node_modules', 'test']
}, function(err, content, next) {
console.log('content:', content);
next();
},
function(err, files){
console.log('finished reading files:',files);
});
// the callback for each file can optionally have a filename argument as its 3rd parameter
// and the finishedCallback argument is optional, e.g.
dir.readFiles("./", function(err: any, content: any, filename: string, next: any) {
console.log('processing content of file', filename);
next();
});
dir.files("./", function(err, files) {
console.log(files);
});
dir.files("./", function(err, files) {
// sort descending
files.reverse();
// include only certain filenames
files = files.filter(function(file: any) {
return ['allowed', 'file', 'names'].indexOf(file) > -1;
});
// exclude some filenames
files = files.filter(function(file: any) {
return ['exclude', 'these', 'files'].indexOf(file) === -1;
});
});
dir.subdirs("./", function(err, subdirs) {
console.log(subdirs);
});
dir.paths("./", function(err, paths) {
console.log('files:\n', paths.files);
console.log('subdirs:\n', paths.dirs);
});
dir.paths("./", true, function(err, paths) {
console.log('paths:\n', paths);
});
+65
View File
@@ -0,0 +1,65 @@
// Type definitions for node-dir
// Project: https://github.com/fshost/node-dir
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "node-dir" {
export interface Options {
// file encoding (defaults to 'utf8')
encoding?: string;
// a regex pattern or array to specify filenames to ignore
exclude?: RegExp | string[];
// a regex pattern or array to specify directories to ignore
excludeDir?: RegExp | string[];
// a regex pattern or array to specify filenames to operate on
match?: RegExp | string[];
// a regex pattern or array to specify directories to recurse
matchDir?: RegExp | string[];
// whether to recurse subdirectories when reading files (defaults to true)
recursive?: boolean;
// sort files in each directory in descending order
reverse?: boolean;
// whether to aggregate only the base filename rather than the full filepath
shortName?: boolean;
// sort files in each directory in ascending order (defaults to true)
sort?: boolean;
// control if done function called on error (defaults to true)
doneOnErr?: boolean;
}
export interface FileCallback {
(error: any, content: any, next: () => void): void;
}
export interface FileNamedCallback {
(error: any, content: any, filename: string, next: () => void): void;
}
export interface StreamCallback {
(error: any, stream: any, next: () => void): void;
}
export interface FinishedCallback {
(error: any, files: any): void;
}
export function readFiles(dir: string, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFilesStream(dir: string, options: Options, streamCallback: StreamCallback,
finishedCallback?: FinishedCallback): void;
export function files(dir: string, callback: (error: any, files: any) => void): void;
export function subdirs(dir: string, callback: (error: any, subdirs: any) => void): void;
export function paths(dir: string, callback: (error: any, paths: any) => void): void;
export function paths(dir: string, combine: boolean, callback: (error: any, paths: any) => void): void;
}
+3 -3
View File
@@ -176,7 +176,7 @@ declare module NodeJS {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@@ -1191,8 +1191,8 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
export function randomBytes(size: number): Buffer;
export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
export function pseudoRandomBytes(size: number): Buffer;
+3 -3
View File
@@ -176,7 +176,7 @@ declare module NodeJS {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@@ -1099,8 +1099,8 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
export function randomBytes(size: number): Buffer;
export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
export function pseudoRandomBytes(size: number): Buffer;
+3 -3
View File
@@ -256,7 +256,7 @@ declare module NodeJS {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@@ -1654,8 +1654,8 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer;
export function randomBytes(size: number): Buffer;
+3 -3
View File
@@ -150,7 +150,7 @@ interface NodeProcess extends EventEmitter {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@@ -326,7 +326,7 @@ declare module "cluster" {
export function disconnect(callback?: Function): void;
export var workers: any;
// Event emitter
// Event emitter
export function addListener(event: string, listener: Function): void;
export function on(event: string, listener: Function): any;
export function once(event: string, listener: Function): void;
@@ -970,7 +970,7 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void;
export function randomBytes(size: number, callback?: (err: Error, buf: Buffer) =>void );
}
+156 -11
View File
@@ -32,6 +32,54 @@ assert.doesNotThrow(() => {
if (false) { throw "a hammer at your face"; }
}, undefined, "What the...*crunch*");
////////////////////////////////////////////////////
/// Events tests : http://nodejs.org/api/events.html
////////////////////////////////////////////////////
module events_tests {
let emitter: events.EventEmitter;
let event: string;
let listener: Function;
let any: any;
{
let result: events.EventEmitter;
result = emitter.addListener(event, listener);
result = emitter.on(event, listener);
result = emitter.once(event, listener);
result = emitter.removeListener(event, listener);
result = emitter.removeAllListeners();
result = emitter.removeAllListeners(event);
result = emitter.setMaxListeners(42);
}
{
let result: number;
result = events.EventEmitter.defaultMaxListeners;
result = events.EventEmitter.listenerCount(emitter, event); // deprecated
result = emitter.getMaxListeners();
result = emitter.listenerCount(event);
}
{
let result: Function[];
result = emitter.listeners(event);
}
{
let result: boolean;
result = emitter.emit(event);
result = emitter.emit(event, any);
result = emitter.emit(event, any, any);
result = emitter.emit(event, any, any, any);
}
}
////////////////////////////////////////////////////
/// File system tests : http://nodejs.org/api/fs.html
////////////////////////////////////////////////////
@@ -198,6 +246,13 @@ var ctx: tls.SecureContext = tls.createSecureContext({
});
var blah = ctx.context;
var tlsOpts: tls.TlsOptions = {
host: "127.0.0.1",
port: 55
};
var tlsSocket = tls.connect(tlsOpts);
////////////////////////////////////////////////////
// Make sure .listen() and .close() retuern a Server instance
@@ -226,6 +281,16 @@ module http_tests {
});
var agent: http.Agent = http.globalAgent;
http.request({
agent: false
});
http.request({
agent: agent
});
http.request({
agent: undefined
});
}
////////////////////////////////////////////////////
@@ -421,21 +486,101 @@ module path_tests {
}
////////////////////////////////////////////////////
///ReadLine tests : https://nodejs.org/api/readline.html
/// readline tests : https://nodejs.org/api/readline.html
////////////////////////////////////////////////////
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
module readline_tests {
let rl: readline.ReadLine;
rl.setPrompt("$>");
rl.prompt();
rl.prompt(true);
{
let options: readline.ReadLineOptions;
let input: NodeJS.ReadableStream;
let output: NodeJS.WritableStream;
let completer: readline.Completer;
let terminal: boolean;
rl.question("do you like typescript?", function(answer: string) {
rl.close();
});
let result: readline.ReadLine;
result = readline.createInterface(options);
result = readline.createInterface(input);
result = readline.createInterface(input, output);
result = readline.createInterface(input, output, completer);
result = readline.createInterface(input, output, completer, terminal);
}
{
let prompt: string;
rl.setPrompt(prompt);
}
{
let preserveCursor: boolean;
rl.prompt();
rl.prompt(preserveCursor);
}
{
let query: string;
let callback: (answer: string) => void;
rl.question(query, callback);
}
{
let result: readline.ReadLine;
result = rl.pause();
}
{
let result: readline.ReadLine;
result = rl.resume();
}
{
rl.close();
}
{
let data: string|Buffer;
let key: readline.Key;
rl.write(data);
rl.write(null, key);
}
{
let stream: NodeJS.WritableStream;
let x: number;
let y: number;
readline.cursorTo(stream, x, y);
}
{
let stream: NodeJS.WritableStream;
let dx: number|string;
let dy: number|string;
readline.moveCursor(stream, dx, dy);
}
{
let stream: NodeJS.WritableStream;
let dir: number;
readline.clearLine(stream, dir);
}
{
let stream: NodeJS.WritableStream;
readline.clearScreenDown(stream);
}
}
//////////////////////////////////////////////////////////////////////
/// Child Process tests: https://nodejs.org/api/child_process.html ///
+56 -17
View File
@@ -173,9 +173,11 @@ declare module NodeJS {
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
setMaxListeners(n: number): EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
}
export interface ReadableStream extends EventEmitter {
@@ -256,7 +258,7 @@ declare module NodeJS {
visibility: string;
};
};
kill(pid: number, signal?: string): void;
kill(pid:number, signal?: string|number): void;
pid: number;
title: string;
arch: string;
@@ -423,17 +425,21 @@ declare module "querystring" {
declare module "events" {
export class EventEmitter implements NodeJS.EventEmitter {
static listenerCount(emitter: EventEmitter, event: string): number;
static EventEmitter: EventEmitter;
static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
static defaultMaxListeners: number;
addListener(event: string, listener: Function): EventEmitter;
on(event: string, listener: Function): EventEmitter;
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
setMaxListeners(n: number): EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
}
listenerCount(type: string): number;
}
}
declare module "http" {
@@ -453,7 +459,7 @@ declare module "http" {
path?: string;
headers?: { [key: string]: any };
auth?: string;
agent?: Agent;
agent?: Agent|boolean;
}
export interface Server extends events.EventEmitter {
@@ -826,22 +832,49 @@ declare module "readline" {
import * as events from "events";
import * as stream from "stream";
export interface Key {
sequence?: string;
name?: string;
ctrl?: boolean;
meta?: boolean;
shift?: boolean;
}
export interface ReadLine extends events.EventEmitter {
setPrompt(prompt: string): void;
prompt(preserveCursor?: boolean): void;
question(query: string, callback: Function): void;
pause(): void;
resume(): void;
question(query: string, callback: (answer: string) => void): void;
pause(): ReadLine;
resume(): ReadLine;
close(): void;
write(data: any, key?: any): void;
write(data: string|Buffer, key?: Key): void;
}
export interface Completer {
(line: string): CompleterResult;
(line: string, callback: (err: any, result: CompleterResult) => void): any;
}
export interface CompleterResult {
completions: string[];
line: string;
}
export interface ReadLineOptions {
input: NodeJS.ReadableStream;
output: NodeJS.WritableStream;
completer?: Function;
output?: NodeJS.WritableStream;
completer?: Completer;
terminal?: boolean;
historySize?: number;
}
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
export function createInterface(options: ReadLineOptions): ReadLine;
export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void;
export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
export function clearScreenDown(stream: NodeJS.WritableStream): void;
}
declare module "vm" {
@@ -907,7 +940,11 @@ declare module "child_process" {
export function fork(modulePath: string, args?: string[], options?: {
cwd?: string;
env?: any;
encoding?: string;
execPath?: string;
execArgv?: string[];
silent?: boolean;
uid?: number;
gid?: number;
}): ChildProcess;
export function spawnSync(command: string, args?: string[], options?: {
cwd?: string;
@@ -1535,6 +1572,8 @@ declare module "tls" {
var CLIENT_RENEG_WINDOW: number;
export interface TlsOptions {
host?: string;
port?: number;
pfx?: any; //string or buffer
key?: any; //string or buffer
passphrase?: string;
@@ -1694,10 +1733,10 @@ declare module "crypto" {
setPrivateKey(public_key: string, encoding?: string): void;
}
export function getDiffieHellman(group_name: string): DiffieHellman;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer;
export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer;
export function randomBytes(size: number): Buffer;
export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
export function pseudoRandomBytes(size: number): Buffer;
+1 -1
View File
@@ -191,7 +191,7 @@ function onsTabbar(tabBar: TabbarView): void {
keepPage: true
};
tabBar.setActiveTab(2, options);
var activeTab: number = tabBar.getActiveTab();
var activeTab: number = tabBar.getActiveTabIndex();
tabBar.loadPage('myPage.html');
tabBar.on('eventName', null);
tabBar.once('eventName', null);
+1 -1
View File
@@ -634,7 +634,7 @@ interface TabbarView {
* @return {Number} The index of the currently active tab
* @description Returns tab index on current active tab. If active tab is not found, returns -1
*/
getActiveTab(): number;
getActiveTabIndex(): number;
/**
* @param {String} url Page URL. Can be either an HTML document or an <code>&lt;ons-template&gt;</code>
* @description Displays a new page without changing the active index
-1
View File
@@ -1 +0,0 @@
-1
View File
@@ -1 +0,0 @@
@@ -0,0 +1,212 @@
/// <reference path="./protractor-http-mock.d.ts" />
function TestConfig() {
mock.config = {
rootDirectory: 'root',
protractorConfig: 'protractor.conf.js'
};
}
function TestCtorOverloads() {
let noParam: mock.ProtractorHttpMock = mock();
let emptyArray: mock.ProtractorHttpMock = mock([]);
let mockFiles: mock.ProtractorHttpMock = mock(['mock1', 'mock2']);
let skipDefaults: mock.ProtractorHttpMock = mock([], true);
let del: mock.requests.Delete<number> = {
request: {
path: 'path',
method: 'DELETE'
},
response: {
status: 400,
data: 1
}
};
let put: mock.requests.Put<number> = {
request: {
path: 'path',
method: 'PUT'
},
response: {
status: 400,
data: 1
}
};
let mocks: mock.ProtractorHttpMock = mock([del, put]);
}
function TestTeardown() {
mock.teardown();
}
function TestRequestsMade() {
let values: Array<mock.ReceivedRequest>;
mock.requestsMade().then(v => values = v);
}
function TestClearRequests() {
let promiseValue: boolean;
mock.clearRequests().then(value => {
promiseValue = value;
});
}
function TestGetRequestDefinitions() {
let getMinium: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET'
},
response: {
data: 1,
status: 500
}
};
let getParams: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
params: {
param1: 'param1',
param2: 2
}
},
response: {
data: 1,
status: 500
}
};
let post: mock.requests.Post<number> = {
request: {
path: 'path',
method: 'POST'
},
response: {
data: 1,
status: 500
}
};
let getQueryString: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
queryString: {
query1: 'query1',
query2: 2
}
},
response: {
data: 1,
status: 500
}
};
let getHeaders: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
headers: {
head1: 'head1',
head2: 'head2'
}
},
response: {
data: 1,
status: 500
}
};
}
function TestPostRequestDefinitions() {
let post: mock.requests.Post<number> = {
request: {
path: 'path',
method: 'POST'
},
response: {
data: 1,
status: 500
}
};
let postData: mock.requests.PostData<number, string> = {
request: {
path: 'path',
method: 'POST',
data: 'data'
},
response: {
data: 1,
status: 500
}
};
}
function TestHeadRequestDefinitions() {
let head: mock.requests.Head<number> = {
request: {
path: 'path',
method: 'HEAD'
},
response: {
status: 500,
data: 1
}
};
}
function TestDeleteRequestDefinitions() {
let del: mock.requests.Delete<number> = {
request: {
path: 'path',
method: 'DELETE'
},
response: {
status: 500,
data: 1
}
};
}
function TestPutRequestDefinitions() {
let put: mock.requests.Put<number> = {
request: {
path: 'path',
method: 'PUT'
},
response: {
status: 500,
data: 1
}
};
}
function TestPatchRequestDefinitions() {
let patch: mock.requests.Patch<number> = {
request: {
path: 'path',
method: 'PATCH'
},
response: {
status: 500,
data: 1
}
};
}
function TestJsonpRequestDefinitions() {
let jsonp: mock.requests.Jsonp<number> = {
request: {
path: 'path',
method: 'JSONP'
},
response: {
status: 500,
data: 1
}
};
}
+209
View File
@@ -0,0 +1,209 @@
// Type definitions for protractor-http-mock
// Project: https://github.com/atecarlos/protractor-http-mock
// Definitions by: Crevil <https://github.com/Crevil>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../selenium-webdriver/selenium-webdriver.d.ts" />
declare module mock {
interface ProtractorHttpMock {
/**
* Instantiate mock module. This must be done before the browser connects.
*
* @param mocks An array of mock modules to load into the application.
* @param skipDefaults Set true to skip loading of default mocks.
*/
<T>(mocks?: Array<requests.BaseRequest<T>>, skipDefaults?: boolean): ProtractorHttpMock;
/**
* Instantiate mock modules from files. This must be done before the browser connects.
*
* @param mocks An array of mock module names relative to the rootDirectory configuration.
*/
(mocks: Array<string>): ProtractorHttpMock;
/**
* Clean up.
* Typically done in the afterEach call to ensure the teardown
* is executed regardless of what happens in the test execution.
*/
teardown(): void;
/**
* Returns a promise that will be resolved with an array of
* all matched HTTP requests.
*/
requestsMade(): webdriver.promise.Promise<Array<ReceivedRequest>>;
/**
* Returns a promise that will be resolved with a true boolean
* when all matched HTTP requests are cleared.
*/
clearRequests(): webdriver.promise.Promise<boolean>;
/**
* Module configuration to setup
*/
config: {
/**
* Mocks directory where mock files are located.
* Default: process.cwd()
*/
rootDirectory?: string;
/**
* Path to protractor configuration file.
* Default: protractor.conf
*/
protractorConfig?: string;
};
}
/**
* Matched request.
*/
interface ReceivedRequest {
url: string;
method: string;
}
module requests {
/**
* Base request mock used for all mocks.
*/
interface BaseRequest<TResponse> {
request: {
method: string;
path: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* GET request mock.
*/
interface Get<TResponse> extends BaseRequest<TResponse> {
request: {
method: string;
path: string;
params?: Object;
queryString?: Object;
headers?: Object;
interceptedRequest?: boolean;
interceptedAnonymousRequest?: boolean;
};
response: {
status: number;
data: TResponse;
};
}
/**
* POST request mock with payload.
*/
interface PostData<TResponse, TPayload> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
data: TPayload;
};
response: {
status: number;
data: TResponse;
};
}
/**
* POST request mock.
*/
interface Post<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* HEAD request mock.
*/
interface Head<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* HTTP Delete request mock.
*/
interface Delete<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* PUT request mock.
*/
interface Put<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* PATCH request mock.
*/
interface Patch<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
/**
* JSONP request mock.
*/
interface Jsonp<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
};
response: {
status: number;
data: TResponse;
};
}
}
}
declare var mock: mock.ProtractorHttpMock;
declare module 'protractor-http-mock' {
export = mock;
}
+3 -1
View File
@@ -85,9 +85,11 @@ declare module 'pty.js' {
removeListener(event: string, listener: Function): NodeJS.EventEmitter;
removeAllListeners(event?: string): NodeJS.EventEmitter;
// NOTE: this method is not actually defined in pty.js
setMaxListeners(n: number): void;
setMaxListeners(n: number): NodeJS.EventEmitter;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
}
/**
@@ -1 +0,0 @@
--target es5 --noImplicitAny --jsx react
@@ -1 +0,0 @@
--target es5 --noImplicitAny --experimentalDecorators --jsx react

Some files were not shown because too many files have changed in this diff Show More