Merge branch 'master' into foundation-sites

This commit is contained in:
Sam Vloeberghs
2016-01-05 11:50:06 +01:00
419 changed files with 118273 additions and 5391 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped)
# DefinitelyTyped [![Build Status](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped.png?branch=master)](https://travis-ci.org/DefinitelyTyped/DefinitelyTyped)
[![Join the chat at https://gitter.im/borisyankov/DefinitelyTyped](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-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;
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ declare module angular.material {
show(dialog: MDDialogOptions|MDPresetDialog<any>): angular.IPromise<any>;
confirm(): MDConfirmDialog;
alert(): MDAlertDialog;
hide(response?: any): void;
hide(response?: any): angular.IPromise<any>;
cancel(response?: any): void;
}
+1 -1
View File
@@ -64,7 +64,7 @@ declare module angular.material {
show(dialog: MDDialogOptions|MDAlertDialog|MDConfirmDialog): angular.IPromise<any>;
confirm(): MDConfirmDialog;
alert(): MDAlertDialog;
hide(response?: any): void;
hide(response?: any): angular.IPromise<any>;
cancel(response?: any): void;
}
+1 -1
View File
@@ -83,7 +83,7 @@ declare module angular.material {
show(dialog: IDialogOptions|IAlertDialog|IConfirmDialog): angular.IPromise<any>;
confirm(): IConfirmDialog;
alert(): IAlertDialog;
hide(response?: any): void;
hide(response?: any): angular.IPromise<any>;
cancel(response?: any): void;
}
@@ -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().
+149
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
/**
@@ -1667,6 +1806,16 @@ declare module protractor {
* @return {Protractor} a protractor instance.
*/
forkNewDriverInstance(opt_useSameUrl?: boolean, opt_copyMockModules?: boolean): Protractor;
/**
* Get the processed configuration object that is currently being run. This will contain
* the specs and capabilities properties of the current runner instance.
*
* Set by the runner.
*
* @return {webdriver.promise.Promise<any>} A promise which resolves to the capabilities object.
*/
getProcessedConfig(): webdriver.promise.Promise<any>;
}
/**
+378
View File
@@ -0,0 +1,378 @@
/// <reference path="../angularjs/angular.d.ts"/>
/// <reference path="./angular-strap.d.ts"/>
module angularStrapTests {
import ngStrap = mgcrea.ngStrap;
///////////////////////////////////////////////////////////////////////////
// Modal
///////////////////////////////////////////////////////////////////////////
module modalTests {
interface IDemoCtrlScope extends ngStrap.modal.IModalScope {
showModal: () => void;
}
angular.module('demoApp')
.config($modalConfig)
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: IDemoCtrlScope,
$modal: ngStrap.modal.IModalService): void {
var myModalOptions: ngStrap.modal.IModalOptions = {};
myModalOptions.title = 'My Title';
myModalOptions.content = 'Hello Modal<br />This is a multiline message!';
myModalOptions.show = true;
var myModal = $modal(myModalOptions);
var myOtherModalOptions: ngStrap.modal.IModalOptions = {};
myOtherModalOptions.scope = $scope;
myOtherModalOptions.template = 'modal/docs/modal.demo.tpl.html';
myOtherModalOptions.show = false;
var myOtherModal = $modal(myOtherModalOptions);
$scope.showModal = (): void => {
myOtherModal.$promise.then(myOtherModal.show);
};
}
function $modalConfig($modalProvider: ngStrap.modal.IModalProvider): void {
var defaults: ngStrap.modal.IModalOptions = {
animation: 'am-flip-x'
}
angular.extend($modalProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Aside
///////////////////////////////////////////////////////////////////////////
module asideTests {
angular.module('demoApp')
.config($asideConfig)
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: ngStrap.aside.IAsideScope,
$aside: ngStrap.aside.IAsideService): void {
var myAsideOptions: ngStrap.aside.IAsideOptions = {};
myAsideOptions.title = 'My Title';
myAsideOptions.content = 'My content';
myAsideOptions.show = true;
var myAside = $aside(myAsideOptions);
var myOtherAsideOptions: ngStrap.aside.IAsideOptions = {};
myOtherAsideOptions.scope = $scope;
myOtherAsideOptions.template = 'aside/docs/aside.demo.tpl.html';
var myOtherAside = $aside();
myOtherAside.$promise.then(() => {
myOtherAside.show();
});
}
function $asideConfig($asideProvider: ngStrap.aside.IAsideProvider): void {
var defaults: ngStrap.aside.IAsideOptions = {};
defaults.animation = 'am-fadeAndSlideLeft';
defaults.placement = 'left';
angular.extend($asideProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Alert
///////////////////////////////////////////////////////////////////////////
module alertTests {
angular.module('demoApp')
.config($alertConfig)
.controller('demoCtrl', demoCtrl);
function demoCtrl($scope: ngStrap.alert.IAlertScope,
$alert: ngStrap.alert.IAlertService): void {
var options: ngStrap.alert.IAlertOptions = {};
options.title = 'Holy guacamole!';
options.content = 'Best check yo self, you\'re not looking too good.';
options.placement = 'top';
options.type = 'info';
options.show = true;
var myAlert = $alert();
}
function $alertConfig($alertProvider: ngStrap.alert.IAlertProvider): void {
var defaults: ngStrap.alert.IAlertOptions = {};
defaults.animation = 'am-fade-and-slide-top';
defaults.placement = 'top';
angular.extend($alertProvider.defaults, defaults);
};
}
///////////////////////////////////////////////////////////////////////////
// Tooltip
///////////////////////////////////////////////////////////////////////////
module tooltipTests {
angular.module('demoApp')
.config($tooltipConfig)
.controller('demoDrct', demoDrct);
function demoDrct($tooltip: ngStrap.tooltip.ITooltipService): ng.IDirective {
var drct: ng.IDirective = {};
drct.restrict = 'EA';
drct.link = link;
return drct;
function link(scope: ng.IScope, elem: ng.IAugmentedJQuery, attrs: ng.IAttributes): void {
var options: ngStrap.tooltip.ITooltipOptions = {};
options.title = 'My Title';
$tooltip(elem, options);
}
}
function $tooltipConfig($tooltipProvider: ngStrap.tooltip.ITooltipProvider): void {
var defaults: ngStrap.tooltip.ITooltipOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($tooltipProvider.defaults, defaults);
};
}
///////////////////////////////////////////////////////////////////////////
// Popover
///////////////////////////////////////////////////////////////////////////
module popoverTests {
angular.module('demoApp')
.config($popoverConfig)
.controller('demoDrct', demoDrct);
function demoDrct($popover: ngStrap.popover.IPopoverService): ng.IDirective {
var drct: ng.IDirective = {};
drct.restrict = 'EA';
drct.link = link;
return drct;
function link(scope: ng.IScope, elem: ng.IAugmentedJQuery, attrs: ng.IAttributes): void {
var options: ngStrap.tooltip.ITooltipOptions = {};
options.title = 'My Title';
$popover(elem, options);
}
}
function $popoverConfig($popoverProvider: ngStrap.popover.IPopoverProvider): void {
var defaults: ngStrap.tooltip.ITooltipOptions = {}
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($popoverProvider.defaults, defaults);
};
}
///////////////////////////////////////////////////////////////////////////
// Typeahead
///////////////////////////////////////////////////////////////////////////
module typeaheadTests {
angular.module('myApp')
.config($typeaheadConfig);
function $typeaheadConfig($typeaheadProvider: ngStrap.typeahead.ITypeaheadProvider) {
var defaults: ngStrap.typeahead.ITypeaheadOptions = {}
defaults.animation = 'am-flip-x';
defaults.minLength = 2;
defaults.limit = 8;
angular.extend($typeaheadProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Datepicker
///////////////////////////////////////////////////////////////////////////
module datepickerTests {
angular.module('myApp')
.config($datepickerConfig);
function $datepickerConfig($datepickerProvider: ngStrap.datepicker.IDatepickerProvider): void {
var defaults: ngStrap.datepicker.IDatepickerOptions = {};
defaults.dateFormat = 'dd/MM/yyyy';
defaults.startWeek = 1;
angular.extend($datepickerProvider.defaults, defaults);
};
}
///////////////////////////////////////////////////////////////////////////
// Timepicker
///////////////////////////////////////////////////////////////////////////
module timepickerTests {
angular.module('myApp')
.config($timepickerConfig);
function $timepickerConfig($timepickerProvider: ngStrap.timepicker.ITimepickerProvider): void {
var defaults: ngStrap.timepicker.ITimepickerOptions = {};
defaults.timeFormat = 'HH:mm';
defaults.length = 7;
angular.extend($timepickerProvider.defaults, defaults);
};
}
///////////////////////////////////////////////////////////////////////////
// Select
///////////////////////////////////////////////////////////////////////////
module selectTests {
angular.module('myApp')
.config($selectConfig);
function $selectConfig($selectProvider: ngStrap.select.ISelectProvider): void {
var defaults: ngStrap.select.ISelectOptions = {};
defaults.animation = 'am-flip-x';
defaults.sort = false;
angular.extend($selectProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Tabs
///////////////////////////////////////////////////////////////////////////
module tabTests {
angular.module('myApp')
.config($tabConfig);
function $tabConfig($tabProvider: ngStrap.tab.ITabProvider) {
var defaults: ngStrap.tab.ITabOptions = {};
defaults.animation = 'am-flip-x';
angular.extend($tabProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Collapse
///////////////////////////////////////////////////////////////////////////
module collapseTests {
angular.module('myApp')
.config($collapseConfig);
function $collapseConfig($collapseProvider: ngStrap.collapse.ICollapseProvider):void {
var defaults: ngStrap.collapse.ICollapseOptions = {};
defaults.animation = 'am-flip-x';
angular.extend($collapseProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Dropdown
///////////////////////////////////////////////////////////////////////////
module dropdownTests {
angular.module('myApp')
.config($dropdownConfig);
function $dropdownConfig($dropdownProvider: ngStrap.dropdown.IDropdownProvider):void {
var defaults: ngStrap.dropdown.IDropdownOptions = {};
defaults.animation = 'am-flip-x';
defaults.trigger = 'hover';
angular.extend($dropdownProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Navbar
///////////////////////////////////////////////////////////////////////////
module navbarTests {
angular.module('myApp')
.config($navbarConfig);
function $navbarConfig($navbarProvider: ngStrap.navbar.INavbarProvider):void {
var defaults: ngStrap.navbar.INavbarOptions = {};
defaults.activeClass = 'in';
angular.extend($navbarProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Scrollspy
///////////////////////////////////////////////////////////////////////////
module scrollspyTests {
angular.module('myApp')
.config($scrollspyConfig);
function $scrollspyConfig($scrollspyProvider: ngStrap.scrollspy.IScrollspyProvider):void {
var defaults: ngStrap.scrollspy.IScrollspyOptions = {};
defaults.offset = 0;
defaults.target = 'my-selector';
angular.extend($scrollspyProvider.defaults, defaults);
}
}
///////////////////////////////////////////////////////////////////////////
// Affix
///////////////////////////////////////////////////////////////////////////
module affixTests {
angular.module('myApp')
.config($affixConfig);
function $affixConfig($affixProvider: ngStrap.affix.IAffixProvider):void {
var defaults: ngStrap.affix.IAffixOptions = {};
defaults.offsetTop = 100;
angular.extend($affixProvider.defaults, defaults);
}
}
}
+600
View File
@@ -0,0 +1,600 @@
// Type definitions for angular-strap v2.2.x
// Project: http://mgcrea.github.io/angular-strap/
// Definitions by: Sam Herrmann <https://github.com/samherrmann>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module mgcrea.ngStrap {
///////////////////////////////////////////////////////////////////////////
// Modal
// see http://mgcrea.github.io/angular-strap/#/modals
///////////////////////////////////////////////////////////////////////////
module modal {
interface IModalService {
(config?: IModalOptions): IModal;
}
interface IModalProvider {
defaults: IModalOptions;
}
interface IModal {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface IModalOptions {
animation?: string;
backdropAnimation?: string;
placement?: string;
title?: string;
content?: string;
html?: boolean;
backdrop?: boolean | string;
keyboard?: boolean;
show?: boolean;
container?: string | boolean;
template?: string;
contentTemplate?: string;
prefixEvent?: string;
id?: string;
scope?: ng.IScope;
}
interface IModalScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
}
}
///////////////////////////////////////////////////////////////////////////
// Aside
// see http://mgcrea.github.io/angular-strap/#/asides
///////////////////////////////////////////////////////////////////////////
module aside {
interface IAsideService {
(config?: IAsideOptions): IAside;
}
interface IAsideProvider {
defaults: IAsideOptions;
}
interface IAside {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface IAsideOptions {
animation?: string;
placement?: string;
title?: string;
content?: string;
html?: boolean;
backdrop?: boolean | string;
keyboard?: boolean;
show?: boolean;
container?: string | boolean;
template?: string;
contentTemplate?: string;
scope?: ng.IScope;
}
interface IAsideScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
}
}
///////////////////////////////////////////////////////////////////////////
// Alert
// see http://mgcrea.github.io/angular-strap/#/alerts
///////////////////////////////////////////////////////////////////////////
module alert {
interface IAlertService {
(config?: IAlertOptions): IAlert;
}
interface IAlertProvider {
defaults: IAlertOptions;
}
interface IAlert {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface IAlertOptions {
animation?: string;
placement?: string;
title?: string;
content?: string;
type?: string;
keyboard?: boolean;
show?: boolean;
container?: string | boolean;
template?: string;
duration?: number | boolean;
dismissable?: boolean;
}
interface IAlertScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
}
}
///////////////////////////////////////////////////////////////////////////
// Tooltip
// see http://mgcrea.github.io/angular-strap/#/tooltips
///////////////////////////////////////////////////////////////////////////
module tooltip {
interface ITooltipService {
(element: ng.IAugmentedJQuery, config?: ITooltipOptions): ITooltip;
}
interface ITooltipProvider {
defaults: ITooltipOptions;
}
interface ITooltip {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface ITooltipOptions {
animation?: string;
placement?: string;
trigger?: string;
title?: string;
html?: boolean;
delay?: number | { show: number; hide: number};
container?: string | boolean;
target?: string | ng.IAugmentedJQuery | boolean;
template?: string;
contentTemplate?: string;
prefixEvent?: string;
id?: string;
viewport?: string | { selector: string; padding: string | number };
}
interface ITooltipScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
$setEnabled: (isEnabled: boolean) => void;
}
}
///////////////////////////////////////////////////////////////////////////
// Popover
// see http://mgcrea.github.io/angular-strap/#/popovers
///////////////////////////////////////////////////////////////////////////
module popover {
interface IPopoverService {
(element: ng.IAugmentedJQuery, config?: IPopoverOptions): IPopover;
}
interface IPopoverProvider {
defaults: IPopoverOptions;
}
interface IPopover {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface IPopoverOptions {
animation?: string;
placement?: string;
trigger?: string;
title?: string;
content?: string;
html?: boolean;
delay?: number | { show: number; hide: number };
container?: string | boolean;
target?: string | ng.IAugmentedJQuery | boolean;
template?: string;
contentTemplate?: string;
autoClose?: boolean;
id?: string;
viewport?: string | { selector: string; padding: string | number };
}
interface IPopoverScope extends ng.IScope {
$show: () => void;
$hide: () => void;
$toggle: () => void;
}
}
///////////////////////////////////////////////////////////////////////////
// Typeahead
// see http://mgcrea.github.io/angular-strap/#/typeaheads
///////////////////////////////////////////////////////////////////////////
module typeahead {
interface ITypeaheadService {
(element: ng.IAugmentedJQuery, controller: any, config?: ITypeaheadOptions): ITypeahead;
}
interface ITypeaheadProvider {
defaults: ITypeaheadOptions;
}
interface ITypeahead {
$promise: ng.IPromise<void>;
show: () => void;
hide: () => void;
toggle: () => void;
}
interface ITypeaheadOptions {
animation?: string;
placement?: string;
trigger?: string;
html?: boolean;
delay?: number | { show: number; hide: number };
container?: string | boolean;
template?: string;
limit?: number;
minLength?: number;
autoSelect?: boolean;
comparator?: string;
id?: string;
watchOptions?: boolean;
}
}
///////////////////////////////////////////////////////////////////////////
// Datepicker
// see http://mgcrea.github.io/angular-strap/#/datepickers
///////////////////////////////////////////////////////////////////////////
module datepicker {
interface IDatepickerService {
(element: ng.IAugmentedJQuery, controller: any, config?: IDatepickerOptions): IDatepicker;
}
interface IDatepickerProvider {
defaults: IDatepickerOptions;
}
interface IDatepicker {
update: (date: Date) => void;
updateDisabledDates: (dateRanges: IDatepickerDateRange[]) => void;
select: (dateConstructorArg: string | number | number[], keep: boolean) => void;
setMode: (mode: any) => void;
int: () => void;
destroy: () => void;
show: () => void;
hide: () => void;
}
interface IDatepickerDateRange {
start: Date;
end: Date;
}
interface IDatepickerOptions {
animation?: string;
placement?: string;
trigger?: string;
html?: boolean;
delay?: number | { show: number; hide: number };
container?: string | boolean;
template?: string;
dateFormat?: string;
modelDateFormat?: string;
dateType?: string;
timezone?: string;
autoclose?: boolean;
useNative?: boolean;
minDate?: Date;
maxDate?: Date;
startView?: number;
minView?: number;
startWeek?: number;
startDate?: Date;
iconLeft?: string;
iconRight?: string;
daysOfWeekDisabled?: string;
disabledDates?: IDatepickerDateRange[];
}
}
///////////////////////////////////////////////////////////////////////////
// Timepicker
// see http://mgcrea.github.io/angular-strap/#/timepickers
///////////////////////////////////////////////////////////////////////////
module timepicker {
interface ITimepickerService {
(element: ng.IAugmentedJQuery, controller: any, config?: ITimepickerOptions): ITimepicker;
}
interface ITimepickerProvider {
defaults: ITimepickerOptions;
}
interface ITimepicker {
}
interface ITimepickerOptions {
animation?: string;
placement?: string;
trigger?: string;
html?: boolean;
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
timeFormat?: string;
modelTimeFormat?: string;
timeType?: string;
autoclose?: boolean;
useNative?: boolean;
minTime?: Date; // TODO
maxTime?: Date; // TODO
length?: number;
hourStep?: number;
minuteStep?: number;
secondStep?: number;
roundDisplay?: boolean;
iconUp?: string;
iconDown?: string;
arrowBehaviour?: string;
}
}
///////////////////////////////////////////////////////////////////////////
// Button
// see http://mgcrea.github.io/angular-strap/#/buttons
///////////////////////////////////////////////////////////////////////////
// No definitions for this module
///////////////////////////////////////////////////////////////////////////
// Select
// see http://mgcrea.github.io/angular-strap/#/selects
///////////////////////////////////////////////////////////////////////////
module select {
interface ISelectService {
(element: ng.IAugmentedJQuery, controller: any, config: ISelectOptions): ISelect;
}
interface ISelectProvider {
defaults: ISelectOptions;
}
interface ISelect {
update: (matches: any) => void;
active: (index: number) => number;
select: (index: number) => void;
show: () => void;
hide: () => void;
}
interface ISelectOptions {
animation?: string;
placement?: string;
trigger?: string;
html?: boolean;
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
multiple?: boolean;
allNoneButtons?: boolean;
allText?: string;
noneText?: string;
maxLength?: number;
maxLengthHtml?: string;
sort?: boolean;
placeholder?: string;
iconCheckmark?: string;
id?: string;
}
}
///////////////////////////////////////////////////////////////////////////
// Tabs
// see http://mgcrea.github.io/angular-strap/#/tabs
///////////////////////////////////////////////////////////////////////////
module tab {
interface ITabProvider {
defaults: ITabOptions;
}
interface ITabService {
defaults: ITabOptions;
controller: any;
}
interface ITabOptions {
animation?: string;
template?: string;
navClass?: string;
activeClass?: string;
}
}
///////////////////////////////////////////////////////////////////////////
// Collapses
// see http://mgcrea.github.io/angular-strap/#/collapses
///////////////////////////////////////////////////////////////////////////
module collapse {
interface ICollapseProvider {
defaults: ICollapseOptions;
}
interface ICollapseOptions {
animation?: string;
activeClass?: string;
disallowToggle?: boolean;
startCollapsed?: boolean;
allowMultiple?: boolean;
}
}
///////////////////////////////////////////////////////////////////////////
// Dropdowsn
// see http://mgcrea.github.io/angular-strap/#/dropdowns
///////////////////////////////////////////////////////////////////////////
module dropdown {
interface IDropdownProvider {
defaults: IDropdownOptions;
}
interface IDropdownService {
(element: ng.IAugmentedJQuery, config: IDropdownOptions): IDropdown;
}
interface IDropdown {
show: () => void;
hide: () => void;
destroy: () => void;
}
interface IDropdownOptions {
animation?: string;
placement?: string;
trigger?: string;
html?: boolean;
delay?: number | { show: number; hide: number; };
container?: string | boolean;
template?: string;
}
}
///////////////////////////////////////////////////////////////////////////
// Navbar
// see http://mgcrea.github.io/angular-strap/#/navbars
///////////////////////////////////////////////////////////////////////////
module navbar {
interface INavbarProvider {
defaults: INavbarOptions;
}
interface INavbarOptions {
activeClass?: string;
routeAttr?: string;
}
interface INavbarService {
defaults: INavbarOptions;
}
}
///////////////////////////////////////////////////////////////////////////
// Scrollspy
// see http://mgcrea.github.io/angular-strap/#/scrollspy
///////////////////////////////////////////////////////////////////////////
module scrollspy {
interface IScrollspyProvider {
defaults: IScrollspyOptions;
}
interface IScrollspyService {
(element: ng.IAugmentedJQuery, options: IScrollspyOptions): IScrollspy;
}
interface IScrollspy {
checkOffsets: () => void;
trackElement: (target: any, source: any) => void;
untrackElement: (target: any, source: any) => void;
activate: (index: number) => void;
}
interface IScrollspyOptions {
target?: string;
offset?: number;
}
}
///////////////////////////////////////////////////////////////////////////
// Affix
// see http://mgcrea.github.io/angular-strap/#/affix
///////////////////////////////////////////////////////////////////////////
module affix {
interface IAffixProvider {
defaults: IAffixOptions;
}
interface IAffixService {
(element: ng.IAugmentedJQuery, options: IAffixOptions): IAffix;
}
interface IAffix {
init: () => void;
destroy: () => void;
checkPositionWithEventLoop: () => void;
checkPosition: () => void;
}
interface IAffixOptions {
offsetTop?: number;
offsetBottom?: number;
offsetParent?: number;
offsetUnpin?: number;
}
}
}
@@ -36,4 +36,9 @@ app.controller('Ctrl', ($scope: Scope, $translate: angular.translate.ITranslateS
$scope['changeLanguage'] = function (key: any) {
$translate.use(key);
};
}).run(($filter: ng.IFilterService) => {
var x: string;
x = $filter('translate')('something');
x = $filter('translate')('something', {});
x = $filter('translate')('something', {}, '');
});
+11 -3
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 {
@@ -22,7 +22,7 @@ declare module angular.translate {
interface IStorage {
get(name: string): string;
set(name: string, value: string): void;
put(name: string, value: string): void;
}
interface IStaticFilesLoaderOptions {
@@ -108,3 +108,11 @@ declare module angular.translate {
useLoaderCache(cache?: any): ITranslateProvider;
}
}
declare module angular {
interface IFilterService {
(name:'translate'): {
(translationId: string, interpolateParams?: any, interpolation?: string): string;
};
}
}
+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, {}, {});
});
}
+24 -4
View File
@@ -5,10 +5,27 @@
/// <reference path="../angularjs/angular.d.ts" />
// Support for AMD require
// Support for AMD require and CommonJS
declare module 'angular-ui-router' {
var _: string;
export = _;
// Since angular-ui-router adds providers for a bunch of
// injectable dependencies, it doesn't really return any
// actual data except the plain string 'ui.router'.
//
// As such, I don't think anybody will ever use the actual
// default value of the module. So I've only included the
// the types. (@xogeny)
export type IState = angular.ui.IState;
export type IStateProvider = angular.ui.IStateProvider;
export type IUrlMatcher = angular.ui.IUrlMatcher;
export type IUrlRouterProvider = angular.ui.IUrlRouterProvider;
export type IStateOptions = angular.ui.IStateOptions;
export type IHrefOptions = angular.ui.IHrefOptions;
export type IStateService = angular.ui.IStateService;
export type IResolvedState = angular.ui.IResolvedState;
export type IStateParamsService = angular.ui.IStateParamsService;
export type IUrlRouterService = angular.ui.IUrlRouterService;
export type IUiViewScrollProvider = angular.ui.IUiViewScrollProvider;
export type IType = angular.ui.IType;
}
declare module angular.ui {
@@ -283,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 {
+70
View File
@@ -11,3 +11,73 @@ var treeNode2: AngularUITree.ITreeNode = {
nodes: [treeNode],
title: "test2"
};
// fake jquery node here so that we can pull a pretend
// angular scope element out of it
var dummyJQueryNode: ng.IAugmentedJQuery;
var fakeScope: (ng.IScope | AngularUITree.IParentTreeNodeScope) = dummyJQueryNode.scope();
(<AngularUITree.ITreeNodeScope> fakeScope).node = treeNode;
var treeNodeScope: AngularUITree.ITreeNodeScope = <AngularUITree.ITreeNodeScope> fakeScope;
(<AngularUITree.IParentTreeNodeScope> fakeScope).isParent = (nodeScope: AngularUITree.ITreeNodeScope) => {
return true;
};
var parentTreeNodeScope: AngularUITree.IParentTreeNodeScope = <AngularUITree.IParentTreeNodeScope> fakeScope;
var eventSourceInfo: AngularUITree.IEventSourceInfo = {
cloneModel: {},
nodeScope: treeNodeScope,
index: 0,
nodesScope: parentTreeNodeScope
};
var position: AngularUITree.IPosition = {
dirAx: 0,
dirX: 0,
dirY: 0,
distAxX: 0,
distAxY: 0,
distX: 0,
distY: 0,
lastDirX: 0,
lastDirY: 0,
lastX: 0,
lastY: 0,
moving: true,
nowX: 0,
nowY: 0,
offsetX: 0,
offsetY: 0,
startX: 0,
startY: 0
};
var eventInfo: AngularUITree.IEventInfo = {
source: eventSourceInfo,
dest: {
index: 0,
nodesScope: parentTreeNodeScope
},
elements: {},
pos: position
};
var acceptCallback: AngularUITree.IAcceptCallback = (source: AngularUITree.ITreeNodeScope,
destination: AngularUITree.ITreeNodeScope,
destinationIndex: number) => {
return false;
};
var droppedCallback: AngularUITree.IDroppedCallback = (eventInfo: AngularUITree.IEventInfo) => {
return;
};
var callbacks: AngularUITree.ICallbacks = {
accept: acceptCallback,
dragStart: droppedCallback,
dropped: droppedCallback
};
+65
View File
@@ -3,7 +3,72 @@
// Definitions by: Calvin Fernandez <https://github.com/CalvinFernandez>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../angularjs/angular.d.ts' />
declare module AngularUITree {
interface IEventSourceInfo {
cloneModel: any;
index: number;
nodeScope: ITreeNodeScope;
nodesScope: ITreeNodeScope;
}
interface IPosition {
dirAx: number;
dirX: number;
dirY: number;
distAxX: number;
distAxY: number;
distX: number;
distY: number;
lastDirX: number;
lastDirY: number;
lastX: number;
lastY: number;
moving: boolean;
nowX: number;
nowY: number;
offsetX: number;
offsetY: number;
startX: number;
startY: number;
}
interface IEventInfo {
dest: {
index: number;
nodesScope: IParentTreeNodeScope;
};
elements: any;
pos: IPosition;
source: IEventSourceInfo;
}
interface IAcceptCallback {
(source: ITreeNodeScope, destination: ITreeNodeScope, destinationIndex: number): boolean;
}
interface IDroppedCallback {
(eventInfo: IEventInfo): void;
}
interface ICallbacks {
accept: IAcceptCallback;
dragStart: IDroppedCallback;
dropped: IDroppedCallback;
}
/**
* Internal representation of node in the UI
*/
interface ITreeNodeScope extends ng.IScope {
node: ITreeNode;
}
interface IParentTreeNodeScope extends ITreeNodeScope {
isParent(nodeScope: ITreeNodeScope): boolean;
}
/**
* Node in list
*/
+5
View File
@@ -89,6 +89,9 @@ resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () {
var promise : angular.IPromise<IMyResource>;
var arrayPromise : angular.IPromise<IMyResource[]>;
var json: {
[index: string]: any;
};
promise = resource.$delete();
promise = resource.$delete({ key: 'value' });
@@ -127,6 +130,8 @@ promise = resource.$save(function () { });
promise = resource.$save(function () { }, function () { });
promise = resource.$save({ key: 'value' }, function () { }, function () { });
json = resource.toJSON();
///////////////////////////////////////
// IResourceService
///////////////////////////////////////
+8 -1
View File
@@ -5,6 +5,10 @@
/// <reference path="angular.d.ts" />
declare module 'angular-resource' {
var _: string;
export = _;
}
///////////////////////////////////////////////////////////////////////////////
// ngResource module (angular-resource.js)
@@ -136,12 +140,15 @@ declare module angular.resource {
/** the promise of the original server interaction that created this instance. **/
$promise : angular.IPromise<T>;
$resolved : boolean;
toJSON: () => {
[index: string]: any;
}
}
/**
* Really just a regular Array object with $promise and $resolve attached to it
*/
interface IResourceArray<T> extends Array<T> {
interface IResourceArray<T> extends Array<T & IResource<T>> {
/** the promise of the original server interaction that created this collection. **/
$promise : angular.IPromise<IResourceArray<T>>;
$resolved : boolean;
+16
View File
@@ -35,6 +35,16 @@ declare module angular.route {
// May not always be available. For instance, current will not be available
// to a controller that was not initialized as a result of a route maching.
current?: ICurrentRoute;
/**
* Causes $route service to update the current URL, replacing current route parameters with those specified in newParams.
* Provided property names that match the route's path segment definitions will be interpolated into the
* location's path, while remaining properties will be treated as query params.
*
* @param newParams Object.<string, string> mapping of URL parameter names to values
*/
updateParams(newParams:{[key:string]:string}): void;
}
@@ -118,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
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angulartics v0.19.2
// Type definitions for Angulartics v0.20.2
// Project: http://luisfarzati.github.io/angulartics/
// Definitions by: Steven Fan <https://github.com/stevenfan>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -21,6 +21,7 @@ declare module angulartics {
interface IAnalyticsServiceProvider extends angular.IServiceProvider {
virtualPageviews(value: boolean): void;
excludeRoutes(value: string[]): void;
firstPageview(value: boolean): void;
withBase(value: boolean): void;
withAutoBase(value: boolean): void;
+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;
+440 -241
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -72,6 +72,8 @@ interface Auth0LockStatic {
hide(callback: () => void): void;
logout(callback: () => void): void;
getClient(): Auth0Static;
}
declare var Auth0Lock: Auth0LockStatic;
+2
View File
@@ -51,6 +51,8 @@ interface Auth0UserProfile {
user_id: string;
/** Represents one or more Identities that may be associated with the User. */
identities: Auth0Identity[];
user_metadata?: any;
app_metadata?: any;
}
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
-1
View File
@@ -1 +0,0 @@
--noImplicitAny --module commonjs --target es5
+1
View File
@@ -0,0 +1 @@
/// <reference path="babylon.d.ts" />
+6327
View File
File diff suppressed because it is too large Load Diff
@@ -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;
+1
View File
@@ -43,6 +43,7 @@ declare module Backbone {
interface PersistenceOptions {
url?: string;
data?: any;
beforeSend?: (jqxhr: JQueryXHR) => void;
success?: (modelOrCollection?: any, response?: any, options?: any) => void;
error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
+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;
}
+54
View File
@@ -0,0 +1,54 @@
/// <reference path="./bcryptjs.d.ts"/>
import bcryptjs = require("bcryptjs");
let str: string;
let num: number;
let bool: boolean;
str = bcryptjs.genSaltSync();
str = bcryptjs.genSaltSync(10);
bcryptjs.genSalt((err: Error, salt: string) => {
str = salt;
});
bcryptjs.genSalt(10, (err: Error, salt: string) => {
str = salt;
});
str = bcryptjs.hashSync("string");
str = bcryptjs.hashSync("string", 10);
str = bcryptjs.hashSync("string", "salt");
bcryptjs.hash("string", 10, (err: Error, hash: string) => {
str = hash;
});
bcryptjs.hash("string", 10, (err: Error, hash: string) => {
str = hash;
}, (percent: number) => {
num = percent;
});
bcryptjs.hash("string", "salt", (err: Error, hash: string) => {
str = hash;
});
bcryptjs.hash("string", "salt", (err: Error, hash: string) => {
str = hash;
}, (percent: number) => {
num = percent;
});
bool = bcryptjs.compareSync("string1", "string2");
bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => {
bool = success;
});
bcryptjs.compare("string1", "string2", (err: Error, success: boolean) => {
bool = success;
}, (percent: number) => {
num = percent;
});
num = bcryptjs.getRounds("string");
str = bcryptjs.getSalt("string");
+82
View File
@@ -0,0 +1,82 @@
// Type definitions for bcryptjs v2.3.0
// Project: https://github.com/dcodeIO/bcrypt.js
// Definitions by: Joshua Filby <https://github.com/Joshua-F/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "bcryptjs" {
/**
* Sets the pseudo random number generator to use as a fallback if neither node's crypto module nor the Web Crypto API is available.
* Please note: It is highly important that the PRNG used is cryptographically secure and that it is seeded properly!
* @param random Function taking the number of bytes to generate as its sole argument, returning the corresponding array of cryptographically secure random byte values.
*/
export function setRandomFallback(random: (random: number) => number[]): void;
/**
* Synchronously generates a salt.
* @param rounds Number of rounds to use, defaults to 10 if omitted
* @return Resulting salt
*/
export function genSaltSync(rounds?: number): string;
/**
* Asynchronously generates a salt.
* @param callback Callback receiving the error, if any, and the resulting salt
*/
export function genSalt(callback: (err: Error, salt: string) => void): void;
/**
* Asynchronously generates a salt.
* @param rounds Number of rounds to use, defaults to 10 if omitted
* @param callback Callback receiving the error, if any, and the resulting salt
*/
export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void;
/**
* Synchronously generates a hash for the given string.
* @param s String to hash
* @param salt Salt length to generate or salt to use, default to 10
* @return Resulting hash
*/
export function hashSync(s: string, salt?: number | string): string;
/**
* Asynchronously generates a hash for the given string.
* @param s String to hash
* @param salt Salt length to generate or salt to use
* @param callback Callback receiving the error, if any, and the resulting hash
* @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
*/
export function hash(s: string, salt: number | string, callback: (err: Error, hash: string) => void, progressCallback?: (percent: number) => void): void;
/**
* Synchronously tests a string against a hash.
* @param s String to compare
* @param hash Hash to test against
* @return true if matching, otherwise false
*/
export function compareSync(s: string, hash: string): boolean;
/**
* Asynchronously compares the given data against the given hash.
* @param s Data to compare
* @param hash Data to be compared to
* @param callback Callback receiving the error, if any, otherwise the result
* @param progressCallback Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per MAX_EXECUTION_TIME = 100 ms.
*/
export function compare(s: string, hash: string, callback: (err: Error, success: boolean) => void, progressCallback?: (percent: number) => void): void;
/**
* Gets the number of rounds used to encrypt the specified hash.
* @param hash Hash to extract the used number of rounds from
* @return Number of rounds used
*/
export function getRounds(hash: string): number;
/**
* Gets the salt portion from a hash. Does not validate the hash.
* @param hash Hash to extract the salt from
* @return Extracted salt part
*/
export function getSalt(hash: string): string;
}
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="bezier-easing.d.ts" />
function test_create_from_array() {
let easing: BezierEasing = BezierEasing([0, 0, 1, 0.5]);
}
function test_create_from_params() {
let easing: BezierEasing = BezierEasing(0, 0, 1, 0.5);
}
function test_create_from_builtins() {
let easing: BezierEasing = BezierEasing.css['ease-in'];
}
function test_methods() {
let easing: BezierEasing = BezierEasing.css['ease-in'];
let easedRatio: number = easing.get(0.5);
let points: Array<number> = easing.getPoints();
let stringified: string = easing.toString();
let asCSS: string = easing.toCSS();
}
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for bezier-easing
// Project: https://github.com/gre/bezier-easing
// Definitions by: brian ridley <https://github.com/ptlis/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare interface BezierEasing {
get(ratio: number): number;
getPoints(): Array<number>;
toString(): string;
toCSS(): string;
}
declare function BezierEasing(points: Array<number>): BezierEasing;
declare function BezierEasing(a: number, b: number, c: number, d: number): BezierEasing;
declare namespace BezierEasing {
let css: {
'ease': BezierEasing,
'linear': BezierEasing,
'ease-in': BezierEasing,
'ease-out': BezierEasing,
'ease-in-out': BezierEasing
};
}
+5
View File
@@ -200,4 +200,9 @@ declare module BigJsLibrary {
}
}
declare module "big.js" {
var bigjs : BigJsLibrary.BigJS;
export = bigjs;
}
declare var Big: BigJsLibrary.BigJS;
+170
View File
@@ -0,0 +1,170 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="../bluebird/bluebird.d.ts" />
/// <reference path="blue-tape.d.ts" />
import tape = require('blue-tape');
import P = require('bluebird');
var name: string;
var cb: tape.TestCase;
var opts: tape.TestOptions;
var t: tape.Test;
tape(cb);
tape(name, cb);
tape(opts, cb);
tape(name, opts, cb);
tape(name, (test: tape.Test) => {
t = test;
});
tape.skip(name, cb);
tape.only(name, cb);
var sopts: tape.StreamOptions;
var rs: NodeJS.ReadableStream;
rs = tape.createStream();
rs = tape.createStream(sopts);
var htest: typeof tape;
htest = tape.createHarness();
tape(name, (test: tape.Test) => {
var num: number;
var ms: number;
var value: any;
var actual: any;
var expected: any;
var err: any;
var fn = function() {};
var msg: string;
var exceptionExpected: RegExp | (() => void);
test.plan(num);
test.end();
test.end(err);
test.fail(msg);
test.pass(msg);
test.timeoutAfter(ms);
test.skip(msg);
test.ok(value);
test.ok(value, msg);
test.true(value);
test.true(value, msg);
test.assert(value);
test.assert(value, msg);
test.notOk(value);
test.notOk(value, msg);
test.false(value);
test.false(value, msg);
test.notok(value);
test.notok(value, msg);
test.error(err, msg);
test.ifError(err, msg);
test.ifErr(err, msg);
test.iferror(err, msg);
test.equal(actual, expected);
test.equal(actual, expected, msg);
test.equals(actual, expected);
test.equals(actual, expected, msg);
test.isEqual(actual, expected);
test.isEqual(actual, expected, msg);
test.is(actual, expected);
test.is(actual, expected, msg);
test.strictEqual(actual, expected);
test.strictEqual(actual, expected, msg);
test.strictEquals(actual, expected);
test.strictEquals(actual, expected, msg);
test.notEqual(actual, expected);
test.notEqual(actual, expected, msg);
test.notEquals(actual, expected);
test.notEquals(actual, expected, msg);
test.notStrictEqual(actual, expected);
test.notStrictEqual(actual, expected, msg);
test.notStrictEquals(actual, expected);
test.notStrictEquals(actual, expected, msg);
test.isNotEqual(actual, expected);
test.isNotEqual(actual, expected, msg);
test.isNot(actual, expected);
test.isNot(actual, expected, msg);
test.not(actual, expected);
test.not(actual, expected, msg);
test.doesNotEqual(actual, expected);
test.doesNotEqual(actual, expected, msg);
test.isInequal(actual, expected);
test.isInequal(actual, expected, msg);
test.deepEqual(actual, expected);
test.deepEqual(actual, expected, msg);
test.deepEquals(actual, expected);
test.deepEquals(actual, expected, msg);
test.isEquivalent(actual, expected);
test.isEquivalent(actual, expected, msg);
test.same(actual, expected);
test.same(actual, expected, msg);
test.notDeepEqual(actual, expected);
test.notDeepEqual(actual, expected, msg);
test.notEquivalent(actual, expected);
test.notEquivalent(actual, expected, msg);
test.notDeeply(actual, expected);
test.notDeeply(actual, expected, msg);
test.notSame(actual, expected);
test.notSame(actual, expected, msg);
test.isNotDeepEqual(actual, expected);
test.isNotDeepEqual(actual, expected, msg);
test.isNotDeeply(actual, expected);
test.isNotDeeply(actual, expected, msg);
test.isNotEquivalent(actual, expected);
test.isNotEquivalent(actual, expected, msg);
test.isInequivalent(actual, expected);
test.isInequivalent(actual, expected, msg);
test.deepLooseEqual(actual, expected);
test.deepLooseEqual(actual, expected, msg);
test.looseEqual(actual, expected);
test.looseEqual(actual, expected, msg);
test.looseEquals(actual, expected);
test.looseEquals(actual, expected, msg);
test.notDeepLooseEqual(actual, expected);
test.notDeepLooseEqual(actual, expected, msg);
test.notLooseEqual(actual, expected);
test.notLooseEqual(actual, expected, msg);
test.notLooseEquals(actual, expected);
test.notLooseEquals(actual, expected, msg);
test.throws(fn);
test.throws(fn, msg);
test.throws(fn, exceptionExpected);
test.throws(fn, exceptionExpected, msg);
test.doesNotThrow(fn);
test.doesNotThrow(fn, msg);
test.doesNotThrow(fn, exceptionExpected);
test.doesNotThrow(fn, exceptionExpected, msg);
test.test(name, (st) => {
t = st;
});
test.comment(msg);
});
tape('simple delay', (test) => P.delay(1));
tape('nested tests with promises', function(test) {
test.test('delay1', () => P.delay(1) );
test.test('delay2', () => P.delay(1) );
});
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for blue-tape v0.1.11
// Project: https://github.com/spion/blue-tape
// Definitions by: Haoqun Jiang <https://github.com/sodatea>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../tape/tape.d.ts" />
declare module 'blue-tape' {
import tape = require('tape');
export = tape;
}
+1 -1
View File
@@ -394,7 +394,7 @@ declare class Promise<R> implements Promise.Thenable<R> {
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
*/
// TODO how to model promisifyAll?
static promisifyAll(target: Object): Object;
static promisifyAll(target: Object): any;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
+118 -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);
@@ -756,6 +766,13 @@ func = Promise.promisify(f, obj);
obj = Promise.promisifyAll(obj);
anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback));
anyProm = Promise.fromNode(callback => nodeCallbackFuncErrorOnly(callback));
anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback), {multiArgs : true});
anyProm = Promise.fromNode(callback => nodeCallbackFuncErrorOnly(callback), {multiArgs : true});
anyProm = Promise.fromCallback(callback => nodeCallbackFunc(callback));
anyProm = Promise.fromCallback(callback => nodeCallbackFuncErrorOnly(callback));
anyProm = Promise.fromCallback(callback => nodeCallbackFunc(callback), {multiArgs : true});
anyProm = Promise.fromCallback(callback => nodeCallbackFuncErrorOnly(callback), {multiArgs : true});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -1008,6 +1025,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()
+725 -695
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -97,4 +97,3 @@ class Photo extends bookshelf.Model<Photo> {
return this.morphTo('imageable', Site, Post);
}
}
+33 -33
View File
@@ -11,7 +11,7 @@ declare module 'bookshelf' {
import knex = require('knex');
import Promise = require('bluebird');
import Lodash = require('lodash');
interface Bookshelf extends Bookshelf.Events<any> {
VERSION : string;
knex : knex;
@@ -20,9 +20,9 @@ declare module 'bookshelf' {
transaction<T>(callback : (transaction : knex.Transaction) => T) : Promise<T>;
}
function Bookshelf(knex : knex) : Bookshelf;
namespace Bookshelf {
abstract class Events<T> {
on(event? : string, callback? : EventFunction<T>, context? : any) : void;
@@ -31,20 +31,20 @@ declare module 'bookshelf' {
triggerThen(name : string, ...args : any[]) : Promise<any>;
once(event : string, callback : EventFunction<T>, context? : any) : void;
}
interface IModelBase {
/** Should be declared as a getter instead of a plain property. */
hasTimestamps? : boolean|string[];
/** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
tableName? : string;
}
abstract class ModelBase<T extends Model<any>> extends Events<T|Collection<T>> implements IModelBase {
/** If overriding, must use a getter instead of a plain property. */
idAttribute : string;
constructor(attributes? : any, options? : ModelOptions);
clear() : T;
clone() : T;
escape(attribute : string) : string;
@@ -63,7 +63,7 @@ declare module 'bookshelf' {
timestamp(options? : TimestampOptions) : any;
toJSON(options? : SerializeOptions) : any;
unset(attribute : string) : T;
// lodash methods
invert<R extends {}>() : R;
keys() : string[];
@@ -74,7 +74,7 @@ declare module 'bookshelf' {
pick<R extends {}>(...attributes : string[]) : R;
values() : any[];
}
class Model<T extends Model<any>> extends ModelBase<T> {
static collection<T extends Model<any>>(models? : T[], options? : CollectionOptions<T>) : Collection<T>;
static count(column? : string, options? : SyncOptions) : Promise<number>;
@@ -83,7 +83,7 @@ declare module 'bookshelf' {
static fetchAll<T extends Model<any>>() : Promise<Collection<T>>;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes? : any, options? : ModelOptions) : T;
belongsTo<R extends Model<any>>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
belongsToMany<R extends Model<any>>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection<R>;
count(column? : string, options? : SyncOptions) : Promise<number>;
@@ -109,7 +109,7 @@ declare module 'bookshelf' {
where(properties : {[key : string] : any}) : T;
where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T;
}
abstract class CollectionBase<T extends Model<any>> extends Events<T> {
add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection<T>;
at(index : number) : T;
@@ -133,7 +133,7 @@ declare module 'bookshelf' {
toJSON(options? : SerializeOptions) : any;
unshift(model : any, options? : CollectionAddOptions) : void;
where(match : {[key : string] : any}, firstOnly : boolean) : T|Collection<T>;
// lodash methods
all(predicate? : Lodash.ListIterator<T, boolean>|Lodash.DictionaryIterator<T, boolean>|string, thisArg? : any) : boolean;
all<R extends {}>(predicate? : R) : boolean;
@@ -200,13 +200,13 @@ declare module 'bookshelf' {
toArray() : T[];
without(...values : any[]) : T[];
}
class Collection<T extends Model<any>> extends CollectionBase<T> {
/** @deprecated use Typescript classes */
static extend<T>(prototypeProperties? : any, classProperties? : any) : Function;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes? : any, options? : ModelOptions) : T;
attach(ids : any[], options? : SyncOptions) : Promise<Collection<T>>;
count(column? : string, options? : SyncOptions) : Promise<number>;
create(model : {[key : string] : any}, options? : CollectionCreateOptions) : Promise<T>;
@@ -222,92 +222,92 @@ declare module 'bookshelf' {
updatePivot(attributes : any, options? : PivotOptions) : Promise<number>;
withPivot(columns : string[]) : Collection<T>;
}
interface ModelOptions {
tableName? : string;
hasTimestamps? : boolean;
parse? : boolean;
}
interface LoadOptions extends SyncOptions {
withRelated: string|any|any[];
}
interface FetchOptions extends SyncOptions {
require? : boolean;
columns? : string|string[];
withRelated? : string|any|any[];
}
interface FetchAllOptions extends SyncOptions {
require? : boolean;
}
interface SaveOptions extends SyncOptions {
method? : string;
defaults? : string;
patch? : boolean;
require? : boolean;
}
interface SerializeOptions {
shallow? : boolean;
omitPivot? : boolean;
}
interface SetOptions {
unset? : boolean;
}
interface TimestampOptions {
method? : string;
}
interface SyncOptions {
transacting? : knex.Transaction;
debug? : boolean;
}
interface CollectionOptions<T> {
comparator? : boolean|string|((a : T, b : T) => number);
}
interface CollectionAddOptions extends EventOptions {
at? : number;
merge? : boolean;
}
interface CollectionFetchOptions {
require? : boolean;
withRelated? : string|string[];
}
interface CollectionFetchOneOptions {
require? : boolean;
columns? : string|string[];
}
interface CollectionSetOptions extends EventOptions {
add? : boolean;
remove? : boolean;
merge?: boolean;
}
interface PivotOptions {
query? : Function|any;
require? : boolean;
}
interface EventOptions {
silent? : boolean;
}
interface EventFunction<T> {
(model: T, attrs: any, options: any) : Promise<any>|void;
}
interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions {}
}
export = Bookshelf;
}
@@ -54,6 +54,8 @@ declare module BootstrapV3DatetimePicker {
showTodayButton?: boolean;
viewMode?: string;
inline?: boolean;
toolbarPlacement?: string;
showClear?: boolean;
}
interface Datetimepicker {
+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;
+1
View File
@@ -0,0 +1 @@
--target es5 --noImplicitAny --module commonjs
+102
View File
@@ -0,0 +1,102 @@
/**
* Created by Bruno Grieder
*/
///<reference path="./bull.d.ts" />
import * as Queue from "bull"
var videoQueue = Queue( 'video transcoding', 6379, '127.0.0.1' );
var audioQueue = Queue( 'audio transcoding', 6379, '127.0.0.1' );
var imageQueue = Queue( 'image transcoding', 6379, '127.0.0.1' );
videoQueue.process( ( job: Queue.Job, done: Queue.DoneCallback ) => {
// job.data contains the custom data passed when the job was created
// job.jobId contains id of this job.
// transcode video asynchronously and report progress
job.progress( 42 );
// call done when finished
done();
// or give a error if error
done( Error( 'error transcoding' ) );
// or pass it a result
done( null, { framerate: 29.5 /* etc... */ } );
// If the job throws an unhandled exception it is also handled correctly
throw (Error( 'some unexpected error' ));
} );
audioQueue.process( ( job: Queue.Job, done: Queue.DoneCallback ) => {
// transcode audio asynchronously and report progress
job.progress( 42 );
// call done when finished
done();
// or give a error if error
done( Error( 'error transcoding' ) );
// or pass it a result
done( null, { samplerate: 48000 /* etc... */ } );
// If the job throws an unhandled exception it is also handled correctly
throw (Error( 'some unexpected error' ));
} );
imageQueue.process( ( job: Queue.Job, done: Queue.DoneCallback ) => {
// transcode image asynchronously and report progress
job.progress( 42 );
// call done when finished
done();
// or give a error if error
done( Error( 'error transcoding' ) );
// or pass it a result
done( null, { width: 1280, height: 720 /* etc... */ } );
// If the job throws an unhandled exception it is also handled correctly
throw (Error( 'some unexpected error' ));
} );
videoQueue.add( { video: 'http://example.com/video1.mov' } );
audioQueue.add( { audio: 'http://example.com/audio1.mp3' } );
imageQueue.add( { image: 'http://example.com/image1.tiff' } );
//////////////////////////////////////////////////////////////////////////////////
//
// Using Promises
//
//////////////////////////////////////////////////////////////////////////////////
const fetchVideo = ( url: string ): Promise<any> => { return null }
const transcodeVideo = ( data: any ): Promise<void> => { return null }
interface VideoJob extends Queue.Job {
data: {url: string}
}
videoQueue.process( ( job: VideoJob ) => { // don't forget to remove the done callback!
// Simply return a promise
return fetchVideo( job.data.url ).then( transcodeVideo );
// Handles promise rejection
return Promise.reject( new Error( 'error transcoding' ) );
// Passes the value the promise is resolved with to the "completed" event
return Promise.resolve( { framerate: 29.5 /* etc... */ } );
// If the job throws an unhandled exception it is also handled correctly
throw new Error( 'some unexpected error' );
// same as
return Promise.reject( new Error( 'some unexpected error' ) );
} );
+311
View File
@@ -0,0 +1,311 @@
// Type definitions for bull 0.7.0
// Project: https://github.com/OptimalBits/bull
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../redis/redis.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "bull" {
import * as Redis from "redis";
/**
* This is the Queue constructor.
* It creates a new Queue that is persisted in Redis.
* Everytime the same queue is instantiated it tries to process all the old jobs that may exist from a previous unfinished session.
*/
function Bull(queueName: string, redisPort: number, redisHost: string, redisOpt?: Redis.ClientOpts): Bull.Queue;
module Bull {
export interface DoneCallback {
(error?: Error, value?: any): void
}
export interface Job {
id: string
/**
* The custom data passed when the job was created
*/
data: Object;
/**
* Report progress on a job
*/
progress(value: any): Promise<void>;
/**
* Removes a Job from the queue from all the lists where it may be included.
* @returns {Promise} A promise that resolves when the job is removed.
*/
remove(): Promise<void>;
/**
* Rerun a Job that has failed.
* @returns {Promise} A promise that resolves when the job is scheduled for retry.
*/
retry(): Promise<void>;
}
export interface Backoff {
/**
* Backoff type, which can be either `fixed` or `exponential`
*/
type: string
/**
* Backoff delay, in milliseconds
*/
delay: number;
}
export interface AddOptions {
/**
* An amount of miliseconds to wait until this job can be processed.
* Note that for accurate delays, both server and clients should have their clocks synchronized
*/
delay?: number;
/**
* A number of attempts to retry if the job fails [optional]
*/
attempts?: number;
/**
* Backoff setting for automatic retries if the job fails
*/
backoff?: number | Backoff
/**
* A boolean which, if true, adds the job to the right
* of the queue instead of the left (default false)
*/
lifo?: boolean;
/**
* The number of milliseconds after which the job should be fail with a timeout error
*/
timeout?: number;
}
export interface Queue {
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
*
* concurrency: Bull will then call you handler in parallel respecting this max number.
*/
process(concurrency: number, callback: (job: Job, done: DoneCallback) => void): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
* or with a result as second argument as second argument (e.g.: done(null, result);) when the job is successful.
* Errors will be passed as a second argument to the "failed" event;
* results, as a second argument to the "completed" event.
*/
process(callback: (job: Job, done: DoneCallback) => void): void;
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* A promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*
* concurrency: Bull will then call you handler in parallel respecting this max number.
*/
process(concurrency: number, callback: (job: Job) => void): Promise<any>;
/**
* Defines a processing function for the jobs placed into a given Queue.
*
* The callback is called everytime a job is placed in the queue.
* It is passed an instance of the job as first argument.
*
* A promise must be returned to signal job completion.
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
* If it is resolved, its value will be the "completed" event's second argument.
*/
process(callback: (job: Job) => void): Promise<any>;
// process(callback: (job: Job, done?: DoneCallback) => void): Promise<any>;
/**
* Creates a new job and adds it to the queue.
* If the queue is empty the job will be executed directly,
* otherwise it will be placed in the queue and executed as soon as possible.
*/
add(data: Object, opts?: AddOptions): Promise<Job>;
/**
* Returns a promise that resolves when the queue is paused.
* The pause is global, meaning that all workers in all queue instances for a given queue will be paused.
* A paused queue will not process new jobs until resumed,
* but current jobs being processed will continue until they are finalized.
*
* Pausing a queue that is already paused does nothing.
*/
pause(): Promise<void>;
/**
* Returns a promise that resolves when the queue is resumed after being paused.
* The resume is global, meaning that all workers in all queue instances for a given queue will be resumed.
*
* Resuming a queue that is not paused does nothing.
*/
resume(): Promise<void>;
/**
* Returns a promise that returns the number of jobs in the queue, waiting or paused.
* Since there may be other processes adding or processing jobs, this value may be true only for a very small amount of time.
*/
count(): Promise<number>;
/**
* Empties a queue deleting all the input lists and associated jobs.
*/
empty(): Promise<void>;
/**
* Closes the underlying redis client. Use this to perform a graceful shutdown.
*
* `close` can be called from anywhere, with one caveat:
* if called from within a job handler the queue won't close until after the job has been processed
*/
close(): Promise<void>;
/**
* Returns a promise that will return the job instance associated with the jobId parameter.
* If the specified job cannot be located, the promise callback parameter will be set to null.
*/
getJob(jobId: string): Promise<Job>;
/**
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
* You can clean the jobs with the following states: completed, waiting, active, delayed, and failed.
*/
clean(gracePeriod: number, jobsState?: string): Promise<Job[]>;
/**
* Listens to queue events
* 'ready', 'error', 'activ', 'progress', 'completed', 'failed', 'paused', 'resumed', 'cleaned'
*/
on(eventName: string, callback: EventCallback): void;
}
interface EventCallback {
(...args: any[]): void
}
interface ReadyEventCallback extends EventCallback {
(): void;
}
interface ErrorEventCallback extends EventCallback {
(error: Error): void;
}
interface JobPromise {
/**
* Abort this job
*/
cancel(): void
}
interface ActiveEventCallback extends EventCallback {
(job: Job, jobPromise: JobPromise): void;
}
interface ProgressEventCallback extends EventCallback {
(job: Job, progress: any): void;
}
interface CompletedEventCallback extends EventCallback {
(job: Job, result: Object): void;
}
interface FailedEventCallback extends EventCallback {
(job: Job, error: Error): void;
}
interface PausedEventCallback extends EventCallback {
(): void;
}
interface ResumedEventCallback extends EventCallback {
(job?: Job): void;
}
/**
* @see clean() for details
*/
interface CleanedEventCallback extends EventCallback {
(jobs: Job[], type: string): void;
}
}
export = Bull;
}
declare module "bull/lib/priority-queue" {
import * as Bull from "bull";
import * as Redis from "redis";
/**
* This is the Queue constructor of priority queue.
*
* It works same a normal queue, with same function and parameters.
* The only difference is that the Queue#add() allow an options opts.priority
* that could take ["low", "normal", "medium", "hight", "critical"]. If no options provider, "normal" will be taken.
*
* The priority queue will process more often highter priority jobs than lower.
*/
function PQueue(queueName: string, redisPort: number, redisHost: string, redisOpt?: Redis.ClientOpts): PQueue.PriorityQueue;
module PQueue {
export interface AddOptions extends Bull.AddOptions {
/**
* "low", "normal", "medium", "high", "critical"
*/
priority?: string;
}
export interface PriorityQueue extends Bull.Queue {
/**
* Creates a new job and adds it to the queue.
* If the queue is empty the job will be executed directly,
* otherwise it will be placed in the queue and executed as soon as possible.
*/
add(data: Object, opts?: PQueue.AddOptions): Promise<Bull.Job>;
}
}
export = PQueue;
}
+128
View File
@@ -0,0 +1,128 @@
/// <reference path="chai-string.d.ts" />
/// <reference path="../mocha/mocha.d.ts" />
/// <reference path="../node/node.d.ts" />
var should = chai.should();
var assert = chai.assert;
var expect = chai.expect;
var chai_string = require('chai-string');
chai.use(chai_string);
describe('chai-string', function() {
describe('#startsWith', function() {
it('check that', function() {
var obj = { foo: 'hello world' };
expect(obj).to.have.property('foo').that.startsWith('hello');
});
});
describe('#startWith', function() {
it('should return true', function() {
var str = 'abcdef',
prefix = 'abc';
str.should.startWith(prefix);
});
it('should return false', function() {
var str = 'abcdef',
prefix = 'cba';
str.should.not.startWith(prefix);
});
});
describe('#endWith', function() {
it('should return true', function() {
var str = 'abcdef',
suffix = 'def';
str.should.endWith(suffix);
});
it('should return false', function() {
var str = 'abcdef',
suffix = 'fed';
str.should.not.endWith(suffix);
});
});
describe('tdd alias', function() {
beforeEach(function() {
this.str = 'abcdef';
this.str2 = 'a\nb\tc\r d ef';
});
it('.startsWith', function() {
assert.startsWith(this.str, 'abc');
});
it('.notStartsWith', function() {
assert.notStartsWith(this.str, 'cba');
});
it('.endsWith', function() {
assert.endsWith(this.str, 'def');
});
it('.notEndsWith', function() {
assert.notEndsWith(this.str, 'fed');
});
it('.equalIgnoreCase', function() {
assert.equalIgnoreCase(this.str, 'AbCdEf');
});
it('.notEqualIgnoreCase', function() {
assert.notEqualIgnoreCase(this.str, 'abDDD');
});
it('.equalIgnoreSpaces', function() {
assert.equalIgnoreSpaces(this.str, this.str2);
});
it('.notEqualIgnoreSpaces', function() {
assert.notEqualIgnoreSpaces(this.str, this.str2 + 'g');
});
it('.singleLine', function() {
assert.singleLine(this.str);
});
it('.notSingleLine', function() {
assert.notSingleLine("abc\ndef");
});
it('.reverseOf', function() {
assert.reverseOf(this.str, 'fedcba');
});
it('.notReverseOf', function() {
assert.notReverseOf(this.str, 'aaaaa');
});
it('.palindrome', function() {
assert.palindrome('abcba');
assert.palindrome('abccba');
assert.palindrome('');
});
it('.notPalindrome', function() {
assert.notPalindrome(this.str);
});
it('.entriesCount', function() {
assert.entriesCount('abcabd', 'ab', 2);
assert.entriesCount('ababd', 'ab', 2);
assert.entriesCount('abab', 'ab', 2);
assert.entriesCount('', 'ab', 0);
});
});
});
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for chai-string 1.1.4
// Project: https://github.com/onechiporenko/chai-string
// Definitions by: Nick Malaguti <https://github.com/nmalaguti/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../chai/chai.d.ts" />
declare module Chai {
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
startsWith(expected: string, message?: string): Assertion;
startWith(expected: string, message?: string): Assertion;
endsWith(expected: string, message?: string): Assertion;
endWith(expected: string, message?: string): Assertion;
equalIgnoreCase(expected: string, message?: string): Assertion;
equalIgnoreSpaces(expected: string, message?: string): Assertion;
singleLine(message?: string): Assertion;
reverseOf(message?: string): Assertion;
palindrome(message?: string): Assertion;
entriesCount(substr: string, expected: number, message?: string): Assertion;
}
export interface Assert {
startsWith(val: string, exp: string, msg?: string): void;
notStartsWith(val: string, exp: string, msg?: string): void;
endsWith(val: string, exp: string, msg?: string): void;
notEndsWith(val: string, exp: string, msg?: string): void;
equalIgnoreCase(val: string, exp: string, msg?: string): void;
notEqualIgnoreCase(val: string, exp: string, msg?: string): void;
equalIgnoreSpaces(val: string, exp: string, msg?: string): void;
notEqualIgnoreSpaces(val: string, exp: string, msg?: string): void;
singleLine(val: string, msg?: string): void;
notSingleLine(val: string, msg?: string): void;
reverseOf(val: string, exp: string, msg?: string): void;
notReverseOf(val: string, exp: string, msg?: string): void;
palindrome(val: string, msg?: string): void;
notPalindrome(val: string, msg?: string): void;
entriesCount(str: string, substr: string, count: number, msg?: string): void;
}
}
declare module 'chai-string' {
function chaiString(chai: any, utils: any): void;
namespace chaiString {}
export = chaiString;
}
+59
View File
@@ -0,0 +1,59 @@
/// <reference path="chai-things.d.ts" />
import chai = require('chai');
import chaiThings = require('chai-things');
chai.use(chaiThings);
function test_somethingSyntax() {
[].should.not.include.something();
[].should.not.include.something.that.equals(1);
var array = [{ a: 1 }, { b: 2 }];
array.should.include.something();
array.should.include.something.that.deep.equals({ b: 2 });
array.should.include.something.that.not.deep.equals({ b: 2 });
array.should.not.include.something.that.deep.equals({ c: 3 });
array.should.include.something.that.not.deep.equals({ c: 3 });
array.should.include.something.with.property('b', 2);
array.should.not.include.something.with.property('b', 3);
var array2 = [{ a: 'b' }, { a: 'b' }];
array2.should.include.something.that.have.property("a");
array2.should.include.something.that.have.property("a").not.equal("d");
}
function test_somethingVariantsSyntax() {
[].should.not.include.any();
[].should.not.include.any.that.deep.equal({ b: 2 });
var array = [{ a: 1 }, { b: 2 }];
array.should.include.a.thing();
array.should.include.a.thing.that.deep.equals({ b: 2 });
array.should.include.an.item();
array.should.include.an.item.that.deep.equals({ b: 2 });
array.should.include.one.that.deep.equals({ b: 2 });
array.should.include.some();
array.should.include.some.that.deep.equal({ b: 2 });
}
function test_allSyntax() {
[].should.all.equal(1);
[].should.all.not.equal(1);
var array = [1, 1];
array.should.all.equal(1);
array.should.all.not.equal(2);
array.should.not.all.equal(2);
array.should.not.all.not.equal(1);
var array2 = [1, 2];
array2.should.not.all.equal(1);
array2.should.not.all.equal(2);
array2.should.not.all.not.equal(1);
array2.should.not.all.not.equal(2);
var array3 = [{ a: 'b' }, { a: 'c' }];
array3.should.all.have.property("a");
array3.should.all.have.property("a").not.equal("d");
}
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for chai-things
// Project: https://github.com/chaijs/chai-things
// Definitions by: David Broder-Rodgers <https://github.com/DavidBR-SW/>
// Definitions: https://github.com/DavidBR-SW/DefinitelyTyped
/// <reference path="../chai/chai.d.ts" />
declare module Chai {
interface ArrayAssertion {
include: ArrayInclude;
contain: ArrayInclude;
not: ArrayAssertion;
all: Assertion;
}
interface ArrayInclude {
(item: any): any;
a: Item;
an: Item;
one: Something;
some: Something;
something: Something;
any: Anything;
}
interface Anything extends Assertion {
(): any;
that: Assertion
with: Assertion
}
interface Something extends Assertion {
(): any;
that: Assertion
with: Assertion
}
interface Item {
item: Something;
thing: Something;
}
interface Deep {
equals: Equal;
}
}
interface Array<T> {
should: Chai.ArrayAssertion;
}
declare module "chai-things" {
function chaiThings(chai: any, utils: any): void;
export = chaiThings;
}
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 }]');
});
});
+19 -6
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"/>
@@ -19,7 +20,7 @@ declare module Chai {
use(fn: (chai: any, utils: any) => void): any;
assert: AssertStatic;
config: Config;
AssertionError: AssertionError;
AssertionError: typeof AssertionError;
}
export interface ExpectStatic extends AssertionStatic {
@@ -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 {
+2
View File
@@ -136,6 +136,8 @@ interface BarChartOptions extends ChartOptions {
barStrokeWidth?: number;
barValueSpacing?: number;
barDatasetSpacing?: number;
scaleShowHorizontalLines?: boolean;
scaleShowVerticalLines?: boolean;
}
interface RadarChartOptions extends ChartSettings {
+8
View File
@@ -254,3 +254,11 @@ function testOptionsPage() {
});
}
chrome.storage.sync.get("myKey", function (loadedData) {
var myValue: { x: number } = loadedData["myKey"];
});
chrome.storage.onChanged.addListener(function (changes) {
var myNewValue: { x: number } = changes["myKey"].newValue;
var myOldValue: { x: number } = changes["myKey"].oldValue;
});
+39 -38
View File
@@ -1,6 +1,6 @@
// Type definitions for Chrome extension development
// Project: http://developer.chrome.com/extensions/
// Definitions by: Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://gitbus.com/couven92>
// Definitions by: Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://github.com/couven92>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../webrtc/MediaStream.d.ts'/>
@@ -2646,13 +2646,13 @@ declare module chrome.extension {
* Parameter request: The request sent by the calling script.
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response.
*/
addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: () => void) => void): void;
addListener(callback: (request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void;
/**
* @param callback The callback parameter should be a function that looks like this:
* function(runtime.MessageSender sender, function sendResponse) {...};
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one onRequest listener in the same document, then only one may send a response.
*/
addListener(callback: (sender: runtime.MessageSender, sendResponse: () => void) => void): void;
addListener(callback: (sender: runtime.MessageSender, sendResponse: (response: any) => void) => void): void;
}
/**
@@ -5553,7 +5553,7 @@ declare module chrome.runtime {
* Optional parameter message: The message sent by the calling script.
* Parameter sendResponse: Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one onMessage listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until sendResponse is called).
*/
addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
addListener(callback: (message: any, sender: MessageSender, sendResponse: (response: any) => void) => void): void;
}
interface ExtensionConnectEvent extends chrome.events.Event {
@@ -5866,13 +5866,13 @@ declare module chrome.sessions {
* @since Chrome 20.
*/
declare module chrome.storage {
interface StorageArea {
interface StorageArea {
/**
* Gets the amount of space (in bytes) being used by one or more items.
* @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set).
* Parameter bytesInUse: Amount of space being used in storage, in bytes.
*/
getBytesInUse(callback: (bytesInUse: number) => void): void;
getBytesInUse(callback: (bytesInUse: number) => void): void;
/**
* Gets the amount of space (in bytes) being used by one or more items.
* @param key A single key to get the total usage for. Pass in null to get the total usage of all of storage.
@@ -5886,11 +5886,11 @@ declare module chrome.storage {
* @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set).
* Parameter bytesInUse: Amount of space being used in storage, in bytes.
*/
getBytesInUse(keys: string[], callback: (bytesInUse: number) => void): void;
getBytesInUse(keys: string[], callback: (bytesInUse: number) => void): void;
/**
* Removes all items from storage.
* @param callback Optional.
* Callback on success, or on failure (in which case runtime.lastError will be set).
* Callback on success, or on failure (in which case runtime.lastError will be set).
*/
clear(callback?: () => void): void;
/**
@@ -5905,14 +5905,14 @@ declare module chrome.storage {
* Removes one item from storage.
* @param key A single key for items to remove.
* @param callback Optional.
* Callback on success, or on failure (in which case runtime.lastError will be set).
* Callback on success, or on failure (in which case runtime.lastError will be set).
*/
remove(key: string, callback?: () => void): void;
/**
* Removes items from storage.
* @param keys A list of keys for items to remove.
* @param callback Optional.
* Callback on success, or on failure (in which case runtime.lastError will be set).
* Callback on success, or on failure (in which case runtime.lastError will be set).
*/
remove(keys: string[], callback?: () => void): void;
/**
@@ -5920,77 +5920,78 @@ declare module chrome.storage {
* @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
* Parameter items: Object with items in their key-value mappings.
*/
get(callback: (items: Object) => void): void;
get(callback: (items: { [key: string]: any }) => void): void;
/**
* Gets one or more items from storage.
* @param key A single key to get. Pass in null to get the entire contents of storage.
* @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
* Parameter items: Object with items in their key-value mappings.
*/
get(key: string, callback: (items: Object) => void): void;
get(key: string, callback: (items: { [key: string]: any }) => void): void;
/**
* Gets one or more items from storage.
* @param keys A list of keys to get. An empty list or object will return an empty result object. Pass in null to get the entire contents of storage.
* @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
* Parameter items: Object with items in their key-value mappings.
*/
get(keys: string[], callback: (items: Object) => void): void;
get(keys: string[], callback: (items: { [key: string]: any }) => void): void;
/**
* Gets one or more items from storage.
* @param keys A dictionary specifying default values. Pass in null to get the entire contents of storage.
* @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
* Parameter items: Object with items in their key-value mappings.
*/
get(keys: Object, callback: (items: Object) => void): void;
}
get(keys: Object, callback: (items: { [key: string]: any }) => void): void;
}
interface StorageChange {
interface StorageChange {
/** Optional. The new value of the item, if there is a new value. */
newValue?: any;
newValue?: any;
/** Optional. The old value of the item, if there was an old value. */
oldValue?: any;
}
oldValue?: any;
}
interface LocalStorageArea extends StorageArea {
/** The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */
QUOTA_BYTES: number;
}
QUOTA_BYTES: number;
}
interface SyncStorageArea extends StorageArea {
/** @deprecated since Chrome 40. The storage.sync API no longer has a sustained write operation quota. */
MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number;
MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: number;
/** The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError. */
QUOTA_BYTES: number;
QUOTA_BYTES: number;
/** The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set runtime.lastError. */
QUOTA_BYTES_PER_ITEM: number;
QUOTA_BYTES_PER_ITEM: number;
/** The maximum number of items that can be stored in sync storage. Updates that would cause this limit to be exceeded will fail immediately and set runtime.lastError. */
MAX_ITEMS: number;
MAX_ITEMS: number;
/**
* The maximum number of set, remove, or clear operations that can be performed each hour. This is 1 every 2 seconds, a lower ceiling than the short term higher writes-per-minute limit.
* Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError.
*/
MAX_WRITE_OPERATIONS_PER_HOUR: number;
MAX_WRITE_OPERATIONS_PER_HOUR: number;
/**
* The maximum number of set, remove, or clear operations that can be performed each minute. This is 2 per second, providing higher throughput than writes-per-hour over a shorter period of time.
* Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError.
* @since Chrome 40.
*/
MAX_WRITE_OPERATIONS_PER_MINUTE: number;
}
}
interface StorageChangedEvent extends chrome.events.Event {
interface StorageChangedEvent extends chrome.events.Event {
/**
* @param callback
* Parameter changes: Object mapping each key that changed to its corresponding storage.StorageChange for that item.
* Parameter areaName: Since Chrome 22. The name of the storage area ("sync", "local" or "managed") the changes are for.
*/
addListener(callback: (changes: Object, areaName: string) => void): void;
}
addListener(callback: (changes: { [key: string]: StorageChange }, areaName: string) => void): void;
}
/** Items in the local storage area are local to each machine. */
var local: LocalStorageArea;
/** Items in the sync storage area are synced using Chrome Sync. */
var sync: SyncStorageArea;
/**
* Items in the managed storage area are set by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error.
* @since Chrome 33.
@@ -5998,7 +5999,7 @@ declare module chrome.storage {
var managed: StorageArea;
/** Fired when one or more items change. */
var onChanged: StorageChangedEvent;
var onChanged: StorageChangedEvent;
}
////////////////////
@@ -7577,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;
}
/**
-2
View File
@@ -41,9 +41,7 @@ declare module CodeMirror {
off(eventName: string, handler: (doc: CodeMirror.Doc, event: any) => void): void;
}
/** Extend CodeMirror.Doc with a state object, so that the Doc.state.completionActive property is reachable*/
interface Doc {
state: any;
showHint: (options: ShowHintOptions) => void;
}
+5
View File
@@ -390,6 +390,9 @@ declare module CodeMirror {
The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */
on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
/** Expose the state object, so that the Editor.state.completionActive property is reachable*/
state: any;
}
interface EditorFromTextArea extends Editor {
@@ -589,6 +592,8 @@ declare module CodeMirror {
/** The reverse of posFromIndex. */
indexFromPos(object: CodeMirror.Position): number;
/** Expose the state object, so that the Doc.state.completionActive property is reachable*/
state: any;
}
interface LineHandle {
+2 -1
View File
@@ -65,10 +65,11 @@ declare module commander {
*
* @param {String} name
* @param {String} [desc]
* @param {Mixed} [opts]
* @return {Command} the new command
* @api public
*/
command(name:string, desc?:string):ICommand;
command(name:string, desc?:string, opts?: any):ICommand;
/**
* Add an implicit `help [cmd]` subcommand
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="commonmark.d.ts" />
import commonmark = require('commonmark');
function logNode(node: commonmark.Node) {
console.log(
node.destination,
node.firstChild,
node.info,
node.isContainer,
node.lastChild,
node.level,
node.listDelimiter,
node.listStart,
node.listTight,
node.listType,
node.literal,
node.next,
node.onEnter,
node.onExit,
node.parent,
node.prev,
node.sourcepos,
node.title,
node.type);
}
var parser = new commonmark.Parser({ smart: true, time: true });
var node = parser.parse('# a piece of _markdown_');
let w = node.walker();
let step = w.next();
if (step.entering) {
logNode(step.node);
}
let xmlRenderer = new commonmark.XmlRenderer({ sourcepos: true, time: true });
let xml = xmlRenderer.render(node);
console.log(xml);
let htmlRenderer = new commonmark.HtmlRenderer({ safe: true, smart: true, sourcepos: true, time: true});
let html = htmlRenderer.render(node);
console.log(html);
+214
View File
@@ -0,0 +1,214 @@
// Type definitions for commonmark.js 0.22.1
// Project: https://github.com/jgm/commonmark.js
// Definitions by: Nico Jansen <https://github.com/nicojs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module commonmark {
export interface NodeWalkingStep {
/**
* a boolean, which is true when we enter a Node from a parent or sibling, and false when we reenter it from a child
*/
entering: boolean;
/**
* The node belonging to this step
*/
node: Node;
}
export interface NodeWalker {
/**
* Returns an object with properties entering and node. Returns null when we have finished walking the tree.
*/
next(): NodeWalkingStep;
/**
* Resets the iterator to resume at the specified node and setting for entering. (Normally this isn't needed unless you do destructive updates to the Node tree.)
*/
resumeAt(node: Node, entering?: boolean): void;
}
export interface Position extends Array<Array<number>> {
}
export interface ListData {
type?: string,
tight?: boolean,
delimiter?: string,
bulletChar?: string
}
export class Node {
constructor(nodeType: string, sourcepos?: Position);
isContainer: boolean;
/**
* (read-only): one of Text, Softbreak, Hardbreak, Emph, Strong, Html, Link, Image, Code, Document, Paragraph, BlockQuote, Item, List, Heading, CodeBlock, HtmlBlock ThematicBreak.
*/
type: string;
/**
* (read-only): a Node or null.
*/
firstChild: Node;
/**
* (read-only): a Node or null.
*/
lastChild: Node;
/**
* (read-only): a Node or null.
*/
next: Node;
/**
* (read-only): a Node or null.
*/
prev: Node;
/**
* (read-only): a Node or null.
*/
parent: Node;
/**
* (read-only): an Array with the following form: [[startline, startcolumn], [endline, endcolumn]]
*/
sourcepos: Position;
/**
* the literal String content of the node or null.
*/
literal: string;
/**
* link or image destination (String) or null.
*/
destination: string;
/**
* link or image title (String) or null.
*/
title: string;
/**
* fenced code block info string (String) or null.
*/
info: string;
/**
* heading level (Number).
*/
level: number;
/**
* either Bullet or Ordered (or undefined).
*/
listType: string;
/**
* true if list is tight
*/
listTight: boolean;
/**
* a Number, the starting number of an ordered list.
*/
listStart: number;
/**
* a String, either ) or . for an ordered list.
*/
listDelimiter: string;
/**
* used only for CustomBlock or CustomInline.
*/
onEnter: string;
/**
* used only for CustomBlock or CustomInline.
*/
onExit: string;
/**
* Append a Node child to the end of the Node's children.
*/
appendChild(child: Node): void;
/**
* Prepend a Node child to the beginning of the Node's children.
*/
prependChild(child: Node): void;
/**
* Remove the Node from the tree, severing its links with siblings and parents, and closing up gaps as needed.
*/
unlink(): void;
/**
* Insert a Node sibling after the Node.
*/
insertAfter(sibling: Node): void;
/**
* Insert a Node sibling before the Node.
*/
insertBefore(sibling: Node): void;
/**
* Returns a NodeWalker that can be used to iterate through the Node tree rooted in the Node
*/
walker(): NodeWalker;
/**
* Setting the backing object of listType, listTight, listStat and listDelimiter directly.
* Not needed unless creating list nodes directly. Should be fixed from v>0.22.1
* https://github.com/jgm/commonmark.js/issues/74
*/
_listData: ListData;
}
/**
* Instead of converting Markdown directly to HTML, as most converters do, commonmark.js parses Markdown to an AST (abstract syntax tree), and then renders this AST as HTML.
* This opens up the possibility of manipulating the AST between parsing and rendering. For example, one could transform emphasis into ALL CAPS.
*/
export class Parser {
/**
* Constructs a new Parser
*/
constructor(options?: ParserOptions);
parse(input: string): Node;
}
export interface ParserOptions {
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
time?: boolean;
}
export interface HtmlRenderingOptions extends XmlRenderingOptions {
/**
* if true, raw HTML will not be passed through to HTML output (it will be replaced by comments), and potentially unsafe URLs in links and images (those beginning with javascript:, vbscript:, file:, and with a few exceptions data:) will be replaced with empty strings.
*/
safe?: boolean;
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
/**
* if true, source position information for block-level elements will be rendered in the data-sourcepos attribute (for HTML) or the sourcepos attribute (for XML).
*/
sourcepos?: boolean;
}
export class HtmlRenderer {
constructor(options?: HtmlRenderingOptions)
render(root: Node): string;
/**
* Let's you override the softbreak properties of a renderer. So, to make soft breaks render as hard breaks in HTML:
* writer.softbreak = "<br />";
*/
softbreak: string;
/**
* Override the function that will be used to escape (sanitize) the html output. Return value is used to add to the html output
* @param input the input to escape
* @param isAttributeValue indicates wheter or not the input value will be used as value of an html attribute.
*/
escape: (input: string, isAttributeValue: boolean) => string;
}
export interface XmlRenderingOptions {
time?: boolean;
sourcepos?: boolean;
}
export class XmlRenderer {
constructor(options?: XmlRenderingOptions)
render(root: Node): string;
}
}
declare module 'commonmark' {
export = commonmark;
}
+28
View File
@@ -0,0 +1,28 @@
/// <reference path="connect-timeout.d.ts" />
/// <reference path="../body-parser/body-parser.d.ts" />
/// <reference path="../cookie-parser/cookie-parser.d.ts" />
/// <reference path="../express/express.d.ts" />
import express = require("express");
import timeout = require("connect-timeout");
import bodyParser = require("body-parser");
import cookieParser = require("cookie-parser");
// example of using this top-level; note the use of haltOnTimedout
// after every middleware; it will stop the request flow on a timeout
var app = express();
app.use(timeout("5s", { respond: false }));
app.use(bodyParser());
app.use(haltOnTimedout);
app.use(cookieParser());
app.use(haltOnTimedout);
// Add your routes here, etc.
function haltOnTimedout(req: express.Request, res: express.Response, next: Function) {
if (!req.timedout) {
next();
}
}
app.listen(3000);
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for connect-timeout
// Project: https://github.com/expressjs/timeout
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../express/express.d.ts" />
declare module Express {
export interface Request {
/**
* @summary Clears the timeout on the request.
*/
clearTimeout(): void;
/**
*
* @return {boolean} true if timeout fired; false otherwise.
*/
timedout(event: string, message: string): boolean;
}
}
declare module "connect-timeout" {
import express = require("express");
interface TimeoutOptions extends Object {
/**
* @summary Controls if this module will "respond" in the form of forwarding an error.
* @type {boolean}
*/
respond: boolean;
}
function timeout(timeout: string, options?: TimeoutOptions): express.RequestHandler;
export = timeout;
}
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="console-stamp.d.ts" />
import consoleStamp = require("console-stamp");
consoleStamp(console);
var options = {};
consoleStamp(console, options);
var options2 = {
metadata: function ():string {
return 'string';
},
colors: {
stamp: "yellow",
label: "white",
metadata: "green"
},
label: true
};
consoleStamp(console, options2);
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for console-stamp 0.2.0
// Project: https://github.com/starak/node-console-stamp
// Definitions by: Eric Byers <https://github.com/ericbyers/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'console-stamp' {
function consoleStamp(console:{}, options?: {
/**
* A string with date format based on Javascript Date Format
*/
pattern?: string
/**
* If true it will show the label (LOG | INFO | WARN | ERROR)
*/
label?: boolean;
/**
* An array containing the methods to include in the patch
*/
include?: any;
/**
* An array containing the methods to exclude in the patch)
*/
exclude?: any;
/**
* Types can be String, Object (interpreted with util.inspect), or Function. See the test-metadata.js for examples.
* Note that metadata can still be sent as the third parameter (as in vesion 1.6) as a backward compatibillity feature, but this is deprecated.
*/
metadata?: any;
/**
* An object representing a color theme. More info https://www.npmjs.com/package/colors
*/
colors?: {
stamp?: any;
label?: any;
metadata?: any;
};
}): void;
export = consoleStamp;
}
@@ -0,0 +1,20 @@
/// <reference path="contentful-resolve-response.d.ts" />
import resolveResponse = require('contentful-resolve-response');
var response = {
items: [
{
someValue: 'wow',
someLink: {sys: {type: 'Link', linkType: 'Entry', id: 'suchId'}}
}
],
includes: {
Entry: [
{sys: {type: 'Entry', id: 'suchId'}, very: 'doge'}
]
}
};
var items = resolveResponse(response)
console.log(items);
@@ -0,0 +1,9 @@
// Type definitions for contentful-resolve-response v0.1.2
// Project: https://github.com/contentful/contentful-resolve-response
// Definitions by: Anton Karsten <https://github.com/antonkarsten>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'contentful-resolve-response' {
function resolveResponse(response: any): any;
export = resolveResponse;
}
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="cookies.d.ts" />
import * as Cookies from 'cookies';
import * as http from 'http';
const server = http.createServer((req, res) => {
const cookies = new Cookies(req, res);
let unsigned: string,
signed: string,
tampered: string
if (req.url == "/set") {
cookies
// set a regular cookie
.set("unsigned", "foo", { httpOnly: false })
// set a signed cookie
.set("signed", "bar", { signed: true })
// mimic a signed cookie, but with a bogus signature
.set("tampered", "baz")
.set("tampered.sig", "bogus")
res.writeHead(302, { "Location": "/" })
return res.end("Now let's check.")
}
unsigned = cookies.get("unsigned")
signed = cookies.get("signed", { signed: true })
tampered = cookies.get("tampered", { signed: true })
res.writeHead(200, { "Content-Type": "text/plain" })
res.end(
"unsigned expected: foo\n\n" +
"unsigned actual: " + unsigned + "\n\n" +
"signed expected: bar\n\n" +
"signed actual: " + signed + "\n\n" +
"tampered expected: undefined\n\n" +
"tampered: " + tampered + "\n\n"
)
})
+100
View File
@@ -0,0 +1,100 @@
// Type definitions for cookie-parser v0.5.1
// Project: https://github.com/pillarjs/cookies
// Definitions by: Wang Zishi <https://github.com/WangZishi/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "cookies" {
import * as http from "http"
module cookies {
interface ICookies {
/**
* This extracts the cookie with the given name from the
* Cookie header in the request. If such a cookie exists,
* its value is returned. Otherwise, nothing is returned.
*/
get(name: string): string;
/**
* This extracts the cookie with the given name from the
* Cookie header in the request. If such a cookie exists,
* its value is returned. Otherwise, nothing is returned.
*/
get(name: string, opts: IOptions): string;
/**
* This sets the given cookie in the response and returns
* the current context to allow chaining.If the value is omitted,
* an outbound header with an expired date is used to delete the cookie.
*/
set(name: string, value: string): ICookies;
/**
* This sets the given cookie in the response and returns
* the current context to allow chaining.If the value is omitted,
* an outbound header with an expired date is used to delete the cookie.
*/
set(name: string, value: string, opts: IOptions): ICookies;
}
interface IOptions {
/**
* a number representing the milliseconds from Date.now() for expiry
*/
maxAge?: number;
/**
* a Date object indicating the cookie's expiration
* date (expires at the end of session by default).
*/
expires?: Date;
/**
* a string indicating the path of the cookie (/ by default).
*/
path?: string;
/**
* a string indicating the domain of the cookie (no default).
*/
domain?: string;
/**
* a boolean indicating whether the cookie is only to be sent
* over HTTPS (false by default for HTTP, true by default for HTTPS).
*/
secure?: boolean;
/**
* a boolean indicating whether the cookie is only to be sent
* over HTTPS (use this if you handle SSL not in your node process).
*/
secureProxy?: boolean;
/**
* a boolean indicating whether the cookie is only to be sent over HTTP(S),
* and not made available to client JavaScript (true by default).
*/
httpOnly?: boolean;
/**
* a boolean indicating whether the cookie is to be signed (false by default).
* If this is true, another cookie of the same name with the .sig suffix
* appended will also be sent, with a 27-byte url-safe base64 SHA1 value
* representing the hash of cookie-name=cookie-value against the first Keygrip key.
* This signature key is used to detect tampering the next time a cookie is received.
*/
signed?: boolean;
/**
* a boolean indicating whether to overwrite previously set
* cookies of the same name (false by default). If this is true,
* all cookies set during the same request with the same
* name (regardless of path or domain) are filtered out of
* the Set-Cookie header when setting this cookie.
*/
overwrite?: boolean;
}
}
interface CookiesStatic {
new (request: http.IncomingMessage, response: http.ServerResponse): cookies.ICookies;
new (request: http.IncomingMessage, response: http.ServerResponse, keys?: Array<string>): cookies.ICookies;
}
const cookies: CookiesStatic;
export = cookies
}
@@ -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;
}
+8 -13
View File
@@ -1,21 +1,16 @@
/// <reference path="couchbase.d.ts"/>
import couchbase = require('couchbase');
var db = new couchbase.Connection({ bucket: "default" }, function (err) {
if (err) throw err;
var cluster = new couchbase.Cluster('couchbase://127.0.0.1');
var bucket = cluster.openBucket('default');
// TS 0.9.5 bug https://typescript.codeplex.com/workitem/2035, todo: remove cast after fix
(<couchbase.Connection>db).set('testdoc', { name: 'Frank' }, function (err, result) {
if (err) throw err;
bucket.upsert('testdoc', { name: 'Frank' }, (error) => {
if (error) throw error;
var s: string = err.message;
bucket.get('testdoc', (err, result) => {
if (err) throw err;
// TS 0.9.5 bug https://typescript.codeplex.com/workitem/2035, todo: remove cast after fix
(<couchbase.Connection>db).get('testdoc', function (err, result) {
if (err) throw err;
console.log(result.value);
// {name: Frank}
});
console.log(result.value);
// {name: Frank}
});
});
+984 -584
View File
File diff suppressed because it is too large Load Diff
+185
View File
@@ -0,0 +1,185 @@
/// <reference path="./cradle.d.ts" />
import cradle = require("cradle");
cradle.setup({
host: 'living-room.couch',
cache: true,
raw: false,
forceSave: true
});
const connection = new cradle.Connection();
const connection2 = new(cradle.Connection);
const connection3 = new(cradle.Connection)('173.45.66.92');
connection.databases(function(error, response) {});
connection.config(function(error, response) {});
connection.databases(function(error, response) {});
connection.info(function(error, response) {});
connection.stats(function(error, response) {});
connection.activeTasks(function(error, response) {});
connection.uuids(function(error, response) {});
connection.uuids(10, function(error, response) {});
connection.replicate({
source: "database",
target: "targetDatabase"
}, function(error, response) {});
const db = connection.database('starwars');
db.exists(function (error, exists) {
if (error) {
console.log('error', error);
} else if (exists) {
console.log('the force is with you.');
} else {
console.log('database does not exists.');
db.create(function(error){
/* do something if there's an erroror */
/* populate design documents */
});
}
});
db.get<{
name: string;
}>('vader', function (error, doc) {
doc.name; // 'Darth Vader'
});
db.get('luke', function (error, doc) {
doc.prop;
});
db.get(['luke', 'vader'], function (error, doc) {
//
});
db.save('skywalker', {
force: 'light',
name: 'Luke Skywalker'
}, function (error, res) {
if (error) {
// Handle erroror
} else {
// Handle success
}
});
db.save({
force: 'dark', name: 'Darth'
}, function (err, res) {
// Handle response
});
db.save('luke', '1-94B6F82', {
force: 'dark', name: 'Luke'
}, function (err, res) {
// Handle response
});
db.save([
{ name: 'Yoda' },
{ name: 'Han Solo' },
{ name: 'Leia' }
], function (err, res) {
// Handle response
});
db.merge('luke', {jedi: true}, function (err, res) {
// Luke is now a jedi,
// but remains on the dark side of the force.
});
db.view('characters/all', function (err, res) {
res.forEach(function (row: any) {
console.log("%s is on the %s side of the force.", row.name, row.force);
});
});
db.view('characters/all', {group: true, reduce: true} , function (err, res) {
res.forEach(function (row: any) {
console.log("%s is on the %s side of the force.", row.name, row.force);
});
});
db.temporaryView({
map: function (doc: any) {
//
}
}, function (err, res) {
if (err) console.log(err);
console.log(res);
});
db.remove('luke', '1-94B6F82', function (err, res) {
// Handle response
});
db.update('my_designdoc/update_handler_name', 'luke', undefined, { my_param: false }, function (err, res) {
// Handle the response, specified by the update handler
});
db.changes(function (err, list) {
list.forEach(function (change) { console.log(change) });
});
db.changes({ since: 42 }, function (err, list) {
//
});
const feed = db.changes({ since: 42 });
feed.on('change', function (change: any) {
console.log(change);
});
const idAndRevData = {
id: 'luke',
rev: 'my-rev'
};
const attachmentData = {
name: 'fooAttachment.txt',
'Content-Type': 'text/plain',
body: 'Foo document text'
};
db.saveAttachment(idAndRevData, attachmentData, function (err, reply) {
if (err) {
console.dir(err)
return
}
console.dir(reply)
});
db.getAttachment('luke', 'foo.txt', function (err, reply) {
if (err) {
console.dir(err);
return;
}
console.dir(reply);
});
db.removeAttachment('luke', 'foo.txt', function (err, reply) {
if (err) {
console.dir(err);
return;
}
console.dir(reply);
});
db.info(function(error, response) {});
db.all(function(error, response) {});
db.all({
body: {
keys: ['key1', 'key2']
}
}, function(error, response) {});
db.compact(function(error, response) {});
db.compact('design', function(error, response) {});
db.viewCleanup(function(error, response) {});
db.replicate('database', function(error, response) {});
db.replicate('database', {}, function(error, response) {});
+122
View File
@@ -0,0 +1,122 @@
// Type definitions for cradle
// Project: https://github.com/flatiron/cradle
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "cradle" {
interface Options {
host?: string;
hostname?: string;
cache?: boolean;
raw?: boolean;
forceSave?: boolean;
auth?: string | {
username: string;
password: string;
}
ca?: string;
secure?: boolean;
retries?: number;
retryTimeout?: number;
maxSockets?: number;
}
interface Callback {
(error: any, response: any): void;
}
interface ErrorCallback {
(error: any): void;
}
export class Connection {
constructor(uri?: string, port?: number, options?: Options);
database(name: string): Database;
databases(Callback: Callback): void;
config(callback: Callback): void;
info(callback: Callback): void;
stats(callback: Callback): void;
activeTasks(callback: Callback): void;
uuids(callback: Callback): void;
uuids(count: number, callback: Callback): void;
replicate(options: {
source: string | {
url: string;
};
target: string | {
url: string;
};
cancel?: boolean;
continuous?: boolean;
create_target?: boolean;
doc_ids?: string[];
filter?: string;
proxy?: string;
query_params?: any;
}, callback: Callback): void;
}
export interface ChangesOptions {
since: number;
}
export class Database {
name: string;
get(id: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, callback: (error: any, document: T) => void): void;
get(id: string, rev: string, callback: (error: any, document: any) => void): void;
get<T>(id: string, rev: string, callback: (error: any, document: T) => void): void;
get(ids: string[], callback: Callback): void;
save(document: any, callback: Callback): void;
save(id: string, document: any, callback: Callback): void;
save(id: string, revision: string, document: any,
callback: Callback): void;
save<T>(document: T, callback: Callback): void;
save<T>(id: string, document: T, callback: Callback): void;
save<T>(id: string, revision: string, document: T,
callback: Callback): void;
save(documents: any[], callback: Callback): void;
merge(id: string, document: any, callback: Callback): void;
merge<T>(id: string, document: T, callback: Callback): void;
remove(id: string, revision: string, callback: Callback): void;
update(name: string, id: string, queryObject: any, documentBody: any,
callback: Callback): void;
view(name: string, callback: Callback): void;
view(name: string, options: {
group?: boolean;
reduce?: boolean;
key?: string;
startkey?: any;
endkey?: any;
include_docs?: boolean;
limit?: number;
descending?: boolean;
}, callback: Callback): void;
temporaryView(view: any, callback: Callback): void;
create(callback: ErrorCallback): void;
exists(callback: (error: any, exists: boolean) => void): void;
destroy(callback: ErrorCallback): void;
changes(options: ChangesOptions): any;
changes(callback: (error: any, list: any[]) => void): void;
changes(options: ChangesOptions, callback: (error: any,
list: any[]) => void): void;
saveAttachment(idAndRevData: {
id: string;
rev: string;
}, attachmentData: any, callback: Callback): void;
getAttachment(id: string, attachmentName: string,
callback: Callback): void;
removeAttachment(id: string, attachmentName: string,
callback: Callback): void;
info(callback: Callback): void;
all(callback: Callback): void;
all(options: any, callback: Callback): void;
compact(callback: Callback): void;
compact(design: string, callback: Callback): void;
viewCleanup(callback: Callback): void;
replicate(target: string, callback: Callback): void;
replicate(target: string, options: any, callback: Callback): void;
}
export function setup(options: Options): void;
}
+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;
}
+40
View File
@@ -0,0 +1,40 @@
/// <reference path="cucumber.d.ts" />
function StepSample() {
type Callback = cucumber.CallbackStepDefinition;
var step = <cucumber.StepDefinitions>this;
var hook = <cucumber.Hooks>this;
hook.Before(function(scenario, callback){
scenario.isFailed() && callback.pending();
})
hook.Around(function(scenario, runScenario) {
scenario.isFailed() && runScenario(null, function(){
console.log('finish tasks');
});
});
hook.registerHandler('AfterFeatures', function (event, callback) {
callback();
});
step.Given(/^I am on the Cucumber.js GitHub repository$/, function(callback:Callback) {
this.visit('https://github.com/cucumber/cucumber-js', callback);
});
step.When(/^I go to the README file$/, function(title:string, callback:Callback) {
callback.pending();
});
step.Then(/^I should see "(.*)" as the page title$/, { timeout:60*1000}, function(title:string, callback:Callback) {
var pageTitle = this.browser.text('title');
if (title === pageTitle) {
callback();
} else {
callback(new Error("Expected to be on page with title " + title));
}
});
}
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for cucumber-js
// Project: https://github.com/cucumber/cucumber-js
// Definitions by: Abraão Alves <https://github.com/abraaoalves>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module cucumber {
export interface CallbackStepDefinition{
pending : () => Thenable<any>;
(errror?:any):void;
}
interface StepDefinitionCode {
(...stepArgs: Array<string |CallbackStepDefinition>): Thenable<any> | any | void;
}
interface StepDefinitionOptions{
timeout?: number;
}
export interface StepDefinitions {
Given(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
Given(pattern: RegExp | string, code: StepDefinitionCode): void;
When(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
When(pattern: RegExp | string, code: StepDefinitionCode): void;
Then(pattern: RegExp | string, options: StepDefinitionOptions, code: StepDefinitionCode): void;
Then(pattern: RegExp | string, code: StepDefinitionCode): void;
setDefaultTimeout(time:number): void;
}
interface HookScenario{
attach(text: string, mimeType?: string, callback?: (err?:any) => void): void;
isFailed() : boolean;
}
interface HookCode {
(scenario: HookScenario, callback?: CallbackStepDefinition): void;
}
interface AroundCode{
(scenario: HookScenario, runScenario?: (error:string, callback?:Function)=>void): void;
}
export interface Hooks {
Before(code: HookCode): void;
After(code: HookCode): void;
Around(code: AroundCode):void;
setDefaultTimeout(time:number): void;
registerHandler(handlerOption:string, code:(event:any, callback:CallbackStepDefinition) =>void): void;
}
}
declare module 'cucumber'{
export = cucumber;
}
Vendored
+42 -2
View File
@@ -791,7 +791,7 @@ declare module d3 {
/**
* Returns the first non-null element in the selection, or null otherwise.
*/
node(): EventTarget;
node(): Node;
/**
* Returns the total number of elements in the selection.
@@ -854,7 +854,7 @@ declare module d3 {
call(func: (transition: Transition<Datum>, ...args: any[]) => any, ...args: any[]): Transition<Datum>;
empty(): boolean;
node(): EventTarget;
node(): Node;
size(): number;
}
@@ -3032,6 +3032,46 @@ declare module d3 {
padding(padding: number): Pack<T>;
}
export function partition(): Partition<partition.Node>;
export function partition<T extends partition.Node>(): Partition<T>;
module partition {
interface Link<T extends Node> {
source: T;
target: T;
}
interface Node {
parent?: Node;
children?: number;
value?: number;
depth?: number;
x?: number;
y?: number;
dx?: number;
dy?: number;
}
}
export interface Partition<T extends partition.Node> {
nodes(root: T): T[];
links(nodes: T[]): partition.Link<T>[];
children(): (node: T, depth: number) => T[];
children(children: (node: T, depth: number) => T[]): Partition<T>;
sort(): (a: T, b: T) => number;
sort(comparator: (a: T, b: T) => number): Partition<T>;
value(): (node: T) => number;
value(value: (node: T) => number): Partition<T>;
size(): [number, number];
size(size: [number, number]): Partition<T>;
}
export function pie(): Pie<number>;
export function pie<T>(): Pie<T>;
+4
View File
@@ -31,3 +31,7 @@ declare module Dagre{
}
declare var dagre: Dagre.DagreFactory;
declare module "dagre" {
export = dagre;
}
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="debounce.d.ts" />
import debounce from "debounce";
const doThings = () => 1;
debounce(function(){ doThings(); })();
debounce(function(){ doThings(); }, 1000)();
debounce(function(a: string){ doThings(); }, 1000)("foo");
// Immediate true should return the value
const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for compose-function
// Project: https://github.com/component/debounce
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "debounce" {
// Overload on boolean constants would allow us to narrow further,
// but it is not implemented for TypeScript yet
function f<A extends Function>(f: A, interval?: number, immediate?: boolean): A
export default f;
}
+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;
}
}
+6580
View File
File diff suppressed because it is too large Load Diff
+1161 -426
View File
File diff suppressed because it is too large Load Diff

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