mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Merge branch 'master' into auto-generate-contributors.md
Conflicts: CONTRIBUTORS.md
This commit is contained in:
@@ -33,3 +33,5 @@ _infrastructure/tests/build
|
||||
!rx.js
|
||||
|
||||
node_modules
|
||||
|
||||
.sublimets
|
||||
|
||||
@@ -83,6 +83,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](chai-fuzzy/chai-fuzzy.d.ts) [chai-fuzzy](http://chaijs.com/plugins/chai-fuzzy) by [Bart van der Schoor](https://github.com/Bartvds)
|
||||
* [:link:](chai-jquery/chai-jquery.d.ts) [chai-jquery](https://github.com/chaijs/chai-jquery) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid)
|
||||
* [:link:](chalk/chalk.d.ts) [chalk](https://github.com/sindresorhus/chalk) by [Diullei Gomes](https://github.com/Diullei), [Bart van der Schoor](https://github.com/Bartvds)
|
||||
* [:link:](change-case/change-case.d.ts) [change-case](https://github.com/blakeembrey/change-case) by [Asana](https://asana.com)
|
||||
* [:link:](chartjs/chart.d.ts) [Chart.js](https://github.com/nnnick/Chart.js) by [Steve Fenton](https://github.com/Steve-Fenton)
|
||||
* [:link:](devextreme/dx.chartjs.d.ts) [ChartJS](http://js.devexpress.com/WebDevelopment/Charts) by [DevExpress Inc.](http://devexpress.com)
|
||||
* [:link:](checksum/checksum.d.ts) [checksum](https://github.com/dshaw/checksum) by [Rogier Schouten](https://github.com/rogierschouten)
|
||||
@@ -100,6 +101,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](compression/compression.d.ts) [compression](https://github.com/expressjs/compression) by [Santi Albo](https://github.com/santialbo)
|
||||
* [:link:](configstore/configstore.d.ts) [configstore](https://github.com/yeoman/configstore) by [Bart van der Schoor](https://github.com/Bartvds)
|
||||
* [:link:](consolidate/consolidate.d.ts) [consolidate](https://github.com/visionmedia/consolidate.js) by [Carlos Ballesteros Velasco](https://github.com/soywiz)
|
||||
* [:link:](content-type/content-type.d.ts) [content-type](https://github.com/deoxxa/content-type) by [Pine Mizune](https://github.com/pine613)
|
||||
* [:link:](convert-source-map/convert-source-map.d.ts) [convert-source-map](https://github.com/thlorenz/convert-source-map) by [Andrew Gaspar](https://github.com/AndrewGaspar)
|
||||
* [:link:](cookie/cookie.d.ts) [cookie](https://github.com/jshttp/cookie) by [Pine Mizune](https://github.com/pine613)
|
||||
* [:link:](cookie-parser/cookie-parser.d.ts) [cookie-parser](https://github.com/expressjs/cookie-parser) by [Santi Albo](https://github.com/santialbo)
|
||||
@@ -376,6 +378,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](logg/logg.d.ts) [logg](https://github.com/dpup/node-logg) by [Bret Little](https://github.com/blittle)
|
||||
* [:link:](long/long.d.ts) [Long.js](https://github.com/dcodeIO/Long.js) by [Toshihide Hara](https://github.com/kerug)
|
||||
* [:link:](lru-cache/lru-cache.d.ts) [lru-cache](https://github.com/isaacs/node-lru-cache) by [Bart van der Schoor](https://github.com/Bartvds)
|
||||
* [:link:](lscache/lscache.d.ts) [lscache](https://github.com/pamelafox/lscache) by [Chris Martinez](https://github.com/Chris-Martinezz)
|
||||
* [:link:](lunr/lunr.d.ts) [lunr.js](https://github.com/olivernn/lunr.js) by [Sebastian Lenz](https://github.com/sebastian-lenz)
|
||||
* [:link:](lz-string/lz-string.d.ts) [lz-string](https://github.com/pieroxy/lz-string) by [Roman Nikitin](https://github.com/M0ns1gn0r)
|
||||
* [:link:](mapbox/mapbox.d.ts) [Mapbox](https://www.mapbox.com/mapbox.js) by [Maxime Fabre](https://github.com/anahkiasen)
|
||||
@@ -393,6 +396,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](microsoft-live-connect/microsoft-live-connect.d.ts) [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) by [John Vilk](https://github.com/jvilk)
|
||||
* [:link:](azure-mobile-services-client/AzureMobileServicesClient.d.ts) [Microsoft Windows AzureMobile Service](http://www.windowsazure.com/en-us/develop/mobile) by [Morosinotto Daniele](https://github.com/dmorosinotto)
|
||||
* [:link:](mime/mime.d.ts) [mime](https://github.com/broofa/node-mime) by [Jeff Goddard](https://github.com/jedigo)
|
||||
* [:link:](minilog/minilog.d.ts) [minilog v2](https://github.com/mixu/minilog) by [Guido](http://guido.io)
|
||||
* [:link:](minimatch/minimatch.d.ts) [Minimatch](https://github.com/isaacs/minimatch) by [vvakame](https://github.com/vvakame)
|
||||
* [:link:](minimist/minimist.d.ts) [minimist](https://github.com/substack/minimist) by [Bart van der Schoor](https://github.com/Bartvds)
|
||||
* [:link:](mithril/mithril.d.ts) [Mithril](http://lhorie.github.io/mithril) by [Leo Horie](https://github.com/lhorie), [Chris Bowdon](https://github.com/cbowdon)
|
||||
@@ -613,6 +617,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
|
||||
* [:link:](urlrouter/urlrouter.d.ts) [urlrouter](https://github.com/fengmk2/urlrouter) by [soywiz](https://github.com/soywiz)
|
||||
* [:link:](UUID/UUID.d.ts) [UUID.js core](https://github.com/LiosK/UUID.js) by [Jason Jarrett](https://github.com/staxmanade)
|
||||
* [:link:](valerie/valerie.d.ts) [valerie](https://github.com/davewatts/valerie) by [Howard Richards](https://github.com/conficient)
|
||||
* [:link:](validator/validator.d.ts) [validator.js](https://github.com/chriso/validator.js) by [tgfjt](https://github.com/tgfjt)
|
||||
* [:link:](vega/vega.d.ts) [Vega](http://trifacta.github.io/vega) by [Tom Crockett](http://github.com/pelotom)
|
||||
* [:link:](velocity-animate/velocity-animate.d.ts) [Velocity](http://velocityjs.org) by [Greg Smith](https://github.com/smrq)
|
||||
* [:link:](videojs/videojs.d.ts) [Video.js](https://github.com/zencoder/video-js) by [Vincent Bortone](https://github.com/vbortone)
|
||||
|
||||
Vendored
+3
-1
@@ -15,7 +15,9 @@ declare module ng.cookies {
|
||||
// CookieService
|
||||
// see http://docs.angularjs.org/api/ngCookies.$cookies
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookiesService {}
|
||||
interface ICookiesService {
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieStoreService
|
||||
|
||||
@@ -83,7 +83,7 @@ angular.module('http-auth-interceptor', [])
|
||||
}
|
||||
|
||||
}];
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
$httpProvider.interceptors.push(interceptor);
|
||||
}]);
|
||||
|
||||
|
||||
@@ -326,6 +326,47 @@ class SampleDirective2 implements ng.IDirective {
|
||||
|
||||
angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
|
||||
|
||||
angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => {
|
||||
$interpolate(attr['test'])(scope);
|
||||
$interpolate('', true)(scope);
|
||||
$interpolate('', true, 'html')(scope);
|
||||
$interpolate('', true, 'html', true)(scope);
|
||||
var defer = $q.defer();
|
||||
defer.reject();
|
||||
defer.resolve();
|
||||
defer.promise.then(function(d) {
|
||||
return d;
|
||||
}).then(function(): any {
|
||||
return null;
|
||||
}, function(): any {
|
||||
return null;
|
||||
})
|
||||
.catch((): any => {
|
||||
return null;
|
||||
})
|
||||
.finally((): any => {
|
||||
return null;
|
||||
});
|
||||
var promise = new $q((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
|
||||
promise = new $q((resolve, reject) => {
|
||||
reject();
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
promise = new $q<boolean>((resolver, reject) => {
|
||||
resolver(true);
|
||||
reject(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
// test from https://docs.angularjs.org/guide/directive
|
||||
angular.module('docsSimpleDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
|
||||
Vendored
+99
-32
@@ -13,6 +13,11 @@ interface Function {
|
||||
$inject?: string[];
|
||||
}
|
||||
|
||||
// Support AMD require
|
||||
declare module 'angular' {
|
||||
export = angular;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ng module (angular.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -32,6 +37,10 @@ declare module ng {
|
||||
$get: any;
|
||||
}
|
||||
|
||||
interface IAngularBootstrapConfig {
|
||||
strictDi?: boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// see http://docs.angularjs.org/api
|
||||
@@ -46,8 +55,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -55,8 +66,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -64,8 +77,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -73,8 +88,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -82,8 +99,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -91,8 +110,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -100,8 +121,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -109,8 +132,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -118,8 +143,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -127,8 +154,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -136,8 +165,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -145,8 +176,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
|
||||
/**
|
||||
* Creates a deep copy of source, which should be an object or an array.
|
||||
@@ -230,6 +263,7 @@ declare module ng {
|
||||
configFn?: Function): IModule;
|
||||
|
||||
noop(...args: any[]): void;
|
||||
reloadWithDebugInfo(): void;
|
||||
toJson(obj: any, pretty?: boolean): string;
|
||||
uppercase(str: string): string;
|
||||
version: {
|
||||
@@ -412,6 +446,7 @@ declare module ng {
|
||||
$commitViewValue(): void;
|
||||
$rollbackViewValue(): void;
|
||||
$setSubmitted(): void;
|
||||
$setUntouched(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -423,13 +458,13 @@ declare module ng {
|
||||
$setValidity(validationErrorKey: string, isValid: boolean): void;
|
||||
// Documentation states viewValue and modelValue to be a string but other
|
||||
// types do work and it's common to use them.
|
||||
$setViewValue(value: any): void;
|
||||
$setViewValue(value: any, trigger?: string): void;
|
||||
$setPristine(): void;
|
||||
$validate(): void;
|
||||
$setTouched(): void;
|
||||
$setUntouched(): void;
|
||||
$rollbackViewValue(): void;
|
||||
$commitViewValue(revalidate?: boolean): void;
|
||||
$commitViewValue(): void;
|
||||
$isEmpty(value: any): boolean;
|
||||
|
||||
$viewValue: any;
|
||||
@@ -448,6 +483,7 @@ declare module ng {
|
||||
$validators: IModelValidators;
|
||||
$asyncValidators: IAsyncModelValidators;
|
||||
|
||||
$pending: any;
|
||||
$pristine: boolean;
|
||||
$dirty: boolean;
|
||||
$valid: boolean;
|
||||
@@ -479,10 +515,13 @@ declare module ng {
|
||||
* see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
|
||||
*/
|
||||
interface IRootScopeService {
|
||||
[index: string]: any;
|
||||
|
||||
$apply(): any;
|
||||
$apply(exp: string): any;
|
||||
$apply(exp: (scope: IScope) => any): any;
|
||||
|
||||
|
||||
$applyAsync(): any;
|
||||
$applyAsync(exp: string): any;
|
||||
$applyAsync(exp: (scope: IScope) => any): any;
|
||||
|
||||
@@ -491,14 +530,16 @@ declare module ng {
|
||||
$digest(): void;
|
||||
$emit(name: string, ...args: any[]): IAngularEvent;
|
||||
|
||||
$eval(expression?: string, args?: Object): any;
|
||||
$eval(expression?: (scope: IScope) => any, args?: Object): any;
|
||||
$eval(): any;
|
||||
$eval(expression: string, locals?: Object): any;
|
||||
$eval(expression: (scope: IScope) => any, locals?: Object): any;
|
||||
|
||||
$evalAsync(expression?: string): void;
|
||||
$evalAsync(expression?: (scope: IScope) => any): void;
|
||||
$evalAsync(): void;
|
||||
$evalAsync(expression: string): void;
|
||||
$evalAsync(expression: (scope: IScope) => any): void;
|
||||
|
||||
// Defaults to false by the implementation checking strategy
|
||||
$new(isolate?: boolean): IScope;
|
||||
$new(isolate?: boolean, parent?: IScope): IScope;
|
||||
|
||||
/**
|
||||
* Listens on events of a given type. See $emit for discussion of event life cycle.
|
||||
@@ -522,10 +563,7 @@ declare module ng {
|
||||
$watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
|
||||
$parent: IScope;
|
||||
|
||||
$root: IRootScopeService;
|
||||
this: IRootScopeService;
|
||||
|
||||
$id: number;
|
||||
|
||||
// Hidden members
|
||||
@@ -533,9 +571,7 @@ declare module ng {
|
||||
$$phase: any;
|
||||
}
|
||||
|
||||
interface IScope extends IRootScopeService {
|
||||
[index: string]: any;
|
||||
}
|
||||
interface IScope extends IRootScopeService { }
|
||||
|
||||
interface IAngularEvent {
|
||||
/**
|
||||
@@ -703,8 +739,8 @@ declare module ng {
|
||||
}
|
||||
|
||||
interface ILogProvider {
|
||||
debugEnabled(enabled: boolean): ILogProvider;
|
||||
debugEnabled(): boolean;
|
||||
debugEnabled(enabled: boolean): ILogProvider;
|
||||
}
|
||||
|
||||
// We define this as separete interface so we can reopen it later for
|
||||
@@ -812,6 +848,8 @@ declare module ng {
|
||||
*/
|
||||
search(search: string, paramValue: boolean): ILocationService;
|
||||
|
||||
state(): any;
|
||||
state(state: any): ILocationService;
|
||||
url(): string;
|
||||
url(url: string): ILocationService;
|
||||
}
|
||||
@@ -847,12 +885,20 @@ declare module ng {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRootElementService extends JQuery {}
|
||||
|
||||
interface IQResolveReject<T> {
|
||||
(): void;
|
||||
(value: T): void;
|
||||
}
|
||||
/**
|
||||
* $q - service in module ng
|
||||
* A promise/deferred implementation inspired by Kris Kowal's Q.
|
||||
* See http://docs.angularjs.org/api/ng/service/$q
|
||||
*/
|
||||
interface IQService {
|
||||
new (resolver: (resolve: IQResolveReject<any>) => any): IPromise<any>;
|
||||
new (resolver: (resolve: IQResolveReject<any>, reject: IQResolveReject<any>) => any): IPromise<any>;
|
||||
new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
|
||||
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
@@ -955,6 +1001,7 @@ declare module ng {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnchorScrollService {
|
||||
(): void;
|
||||
yOffset: any;
|
||||
}
|
||||
|
||||
interface IAnchorScrollProvider extends IServiceProvider {
|
||||
@@ -1014,6 +1061,8 @@ declare module ng {
|
||||
|
||||
imgSrcSanitizationWhitelist(): RegExp;
|
||||
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
|
||||
|
||||
debugInfoEnabled(enabled?: boolean): any;
|
||||
}
|
||||
|
||||
interface ICloneAttachFunction {
|
||||
@@ -1048,6 +1097,7 @@ declare module ng {
|
||||
interface IControllerProvider extends IServiceProvider {
|
||||
register(name: string, controllerConstructor: Function): void;
|
||||
register(name: string, dependencyAnnotatedConstructor: any[]): void;
|
||||
allowGlobals(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1227,10 +1277,22 @@ declare module ng {
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IHttpProviderDefaults {
|
||||
xsrfCookieName?: string;
|
||||
xsrfHeaderName?: string;
|
||||
headers?: {
|
||||
common?: any;
|
||||
post?: any;
|
||||
put?: any;
|
||||
patch?: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface IHttpProvider extends IServiceProvider {
|
||||
defaults: IRequestConfig;
|
||||
defaults: IHttpProviderDefaults;
|
||||
interceptors: any[];
|
||||
responseInterceptors: any[];
|
||||
useApplyAsync(): boolean;
|
||||
useApplyAsync(value: boolean): IHttpProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -1249,7 +1311,7 @@ declare module ng {
|
||||
// see http://docs.angularjs.org/api/ng.$interpolateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IInterpolateService {
|
||||
(text: string, mustHaveExpression?: boolean): IInterpolationFunction;
|
||||
(text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
|
||||
endSymbol(): string;
|
||||
startSymbol(): string;
|
||||
}
|
||||
@@ -1345,6 +1407,11 @@ declare module ng {
|
||||
* @return A promise whose value is the template content.
|
||||
*/
|
||||
(tpl: string, ignoreRequestError?: boolean): IPromise<string>;
|
||||
/**
|
||||
* total amount of pending template requests being downloaded.
|
||||
* @type {number}
|
||||
*/
|
||||
totalPendingRequests: number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -1364,7 +1431,7 @@ declare module ng {
|
||||
instanceAttributes: IAttributes,
|
||||
controller: any,
|
||||
transclude: ITranscludeFunction
|
||||
): void;
|
||||
): void;
|
||||
}
|
||||
|
||||
interface IDirectivePrePost {
|
||||
@@ -1377,7 +1444,7 @@ declare module ng {
|
||||
templateElement: IAugmentedJQuery,
|
||||
templateAttributes: IAttributes,
|
||||
transclude: ITranscludeFunction
|
||||
): IDirectivePrePost;
|
||||
): IDirectivePrePost;
|
||||
}
|
||||
|
||||
interface IDirective {
|
||||
|
||||
@@ -0,0 +1,882 @@
|
||||
/// <reference path="bluebird-1.0.d.ts" />
|
||||
|
||||
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// Note: try to maintain the ordering and separators, and keep to the pattern
|
||||
|
||||
var obj: Object;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
var str: string;
|
||||
var err: Error;
|
||||
var x: any;
|
||||
var f: Function;
|
||||
var func: Function;
|
||||
var arr: any[];
|
||||
var exp: RegExp;
|
||||
var anyArr: any[];
|
||||
var strArr: string[];
|
||||
var numArr: number[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var value: any;
|
||||
var reason: any;
|
||||
var insanity: any;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface Foo {
|
||||
foo(): string;
|
||||
}
|
||||
interface Bar {
|
||||
bar(): string;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface StrFooMap {
|
||||
[key:string]:Foo;
|
||||
}
|
||||
|
||||
interface StrBarMap {
|
||||
[key:string]:Bar;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface StrFooArrMap {
|
||||
[key:string]:Foo[];
|
||||
}
|
||||
|
||||
interface StrBarArrMap {
|
||||
[key:string]:Bar[];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var foo: Foo;
|
||||
var bar: Bar;
|
||||
|
||||
var fooArr: Foo[];
|
||||
var barArr: Bar[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numProm: Promise<number>;
|
||||
var strProm: Promise<string>;
|
||||
var anyProm: Promise<any>;
|
||||
var boolProm: Promise<boolean>;
|
||||
var objProm: Promise<Object>;
|
||||
var voidProm: Promise<void>;
|
||||
|
||||
var fooProm: Promise<Foo>;
|
||||
var barProm: Promise<Bar>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
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 fooThen: Promise.Thenable<Foo>;
|
||||
var barThen: Promise.Thenable<Bar>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numArrProm: Promise<number[]>;
|
||||
var strArrProm: Promise<string[]>;
|
||||
var anyArrProm: Promise<any[]>;
|
||||
|
||||
var fooArrProm: Promise<Foo[]>;
|
||||
var barArrProm: Promise<Bar[]>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numArrThen: Promise.Thenable<number[]>;
|
||||
var strArrThen: Promise.Thenable<string[]>;
|
||||
var anyArrThen: Promise.Thenable<any[]>;
|
||||
|
||||
var fooArrThen: Promise.Thenable<Foo[]>;
|
||||
var barArrThen: Promise.Thenable<Bar[]>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numPromArr: Promise<number>[];
|
||||
var strPromArr: Promise<string>[];
|
||||
var anyPromArr: Promise<any>[];
|
||||
|
||||
var fooPromArr: Promise<Foo>[];
|
||||
var barPromArr: Promise<Bar>[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numThenArr: Promise.Thenable<number>[];
|
||||
var strThenArr: Promise.Thenable<string>[];
|
||||
var anyThenArr: Promise.Thenable<any>[];
|
||||
|
||||
var fooThenArr: Promise.Thenable<Foo>[];
|
||||
var barThenArr: Promise.Thenable<Bar>[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// booya!
|
||||
var fooThenArrThen: Promise.Thenable<Promise.Thenable<Foo>[]>;
|
||||
var barThenArrThen: Promise.Thenable<Promise.Thenable<Bar>[]>;
|
||||
|
||||
var fooResolver: Promise.Resolver<Foo>;
|
||||
var barResolver: Promise.Resolver<Bar>;
|
||||
|
||||
var fooInspection: Promise.Inspection<Foo>;
|
||||
var barInspection: Promise.Inspection<Bar>;
|
||||
|
||||
var fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
|
||||
var barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
|
||||
|
||||
var BlueBird: typeof Promise;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooThen = fooProm;
|
||||
barThen = barProm;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = new Promise((resolve: (value: Foo) => void, reject: (reason: any) => void) => {
|
||||
if (bool) {
|
||||
resolve(foo);
|
||||
}
|
||||
else {
|
||||
reject(new Error(str));
|
||||
}
|
||||
});
|
||||
fooProm = new Promise((resolve: (value: Foo) => void) => {
|
||||
if (bool) {
|
||||
resolve(foo);
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// needs a hint when used untyped?
|
||||
fooProm = new Promise<Foo>((resolve, reject) => {
|
||||
if (bool) {
|
||||
resolve(fooThen);
|
||||
}
|
||||
else {
|
||||
reject(new Error(str));
|
||||
}
|
||||
});
|
||||
fooProm = new Promise<Foo>((resolve) => {
|
||||
resolve(fooThen);
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooResolver.resolve(foo);
|
||||
|
||||
fooResolver.reject(err);
|
||||
|
||||
fooResolver.progress(bar);
|
||||
|
||||
fooResolver.callback = (err: any, value: Foo) => {
|
||||
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooInspection.isFulfilled();
|
||||
|
||||
bool = fooInspection.isRejected();
|
||||
|
||||
bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.error();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.catch((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
barProm = fooProm.catch((reason: any) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught((reason: any) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.catch(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.error((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
return foo;
|
||||
});
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.timeout(num);
|
||||
fooProm = fooProm.timeout(num, str);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm.nodeify();
|
||||
fooProm = fooProm.nodeify((err: any) => {
|
||||
|
||||
});
|
||||
fooProm = fooProm.nodeify((err: any, foo?: Foo) => {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.cancel<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.cancellable();
|
||||
fooProm = fooProm.uncancellable();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooProm.isCancellable();
|
||||
bool = fooProm.isFulfilled();
|
||||
bool = fooProm.isRejected();
|
||||
bool = fooProm.isPending();
|
||||
bool = fooProm.isResolved();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooInspection = fooProm.inspect();
|
||||
|
||||
anyProm = fooProm.call(str);
|
||||
anyProm = fooProm.call(str, 1, 2, 3);
|
||||
|
||||
//TODO enable get() test when implemented
|
||||
// barProm = fooProm.get(str);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.return(bar);
|
||||
barProm = fooProm.thenReturn(bar);
|
||||
|
||||
voidProm = fooProm.return();
|
||||
voidProm = fooProm.thenReturn();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooProm
|
||||
fooProm = fooProm.throw(err);
|
||||
fooProm = fooProm.thenThrow(err);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
str = fooProm.toString();
|
||||
|
||||
obj = fooProm.toJSON();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.all<Bar>();
|
||||
|
||||
objProm = fooProm.props();
|
||||
|
||||
barInspectionArrProm = fooProm.settle<Bar>();
|
||||
|
||||
barProm = fooProm.any<Bar>();
|
||||
|
||||
barArrProm = fooProm.some<Bar>(num);
|
||||
|
||||
barProm = fooProm.race<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
});
|
||||
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
func = Promise.method(function () {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.resolve(foo);
|
||||
fooProm = Promise.resolve(fooThen);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidProm = Promise.reject(reason);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooResolver = Promise.defer<Foo>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.cast(foo);
|
||||
fooProm = Promise.cast(fooThen);
|
||||
|
||||
voidProm = Promise.bind(x);
|
||||
|
||||
bool = Promise.is(value);
|
||||
|
||||
Promise.longStackTraces();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO enable delay
|
||||
|
||||
fooProm = Promise.delay(fooThen, num);
|
||||
fooProm = Promise.delay(foo, num);
|
||||
voidProm = Promise.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
func = Promise.promisify(f);
|
||||
func = Promise.promisify(f, obj);
|
||||
;
|
||||
|
||||
obj = Promise.promisifyAll(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO enable generator
|
||||
/*
|
||||
func = Promise.coroutine(f);
|
||||
|
||||
barProm = Promise.spawn<number>(f);
|
||||
*/
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
BlueBird = Promise.noConflict();
|
||||
|
||||
Promise.onPossiblyUnhandledRejection((reason: any) => {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooArrProm = Promise.all(fooThenArrThen);
|
||||
fooArrProm = Promise.all(fooArrProm);
|
||||
fooArrProm = Promise.all(fooThenArr);
|
||||
fooArrProm = Promise.all(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
objProm = Promise.props(objProm);
|
||||
objProm = Promise.props(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooInspectionArrProm = Promise.settle(fooThenArrThen);
|
||||
fooInspectionArrProm = Promise.settle(fooArrProm);
|
||||
fooInspectionArrProm = Promise.settle(fooThenArr);
|
||||
fooInspectionArrProm = Promise.settle(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.any(fooThenArrThen);
|
||||
fooProm = Promise.any(fooArrProm);
|
||||
fooProm = Promise.any(fooThenArr);
|
||||
fooProm = Promise.any(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.race(fooThenArrThen);
|
||||
fooProm = Promise.race(fooArrProm);
|
||||
fooProm = Promise.race(fooThenArr);
|
||||
fooProm = Promise.race(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooArrProm = Promise.some(fooThenArrThen, num);
|
||||
fooArrProm = Promise.some(fooArrThen, num);
|
||||
fooArrProm = Promise.some(fooThenArr, num);
|
||||
fooArrProm = Promise.some(fooArr, num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooArrProm = Promise.join(foo, foo, foo);
|
||||
fooArrProm = Promise.join(fooThen, fooThen, fooThen);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// map()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
barArrProm = Promise.map(fooArr, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// reduce()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// filter()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Vendored
+670
@@ -0,0 +1,670 @@
|
||||
// Type definitions for bluebird 1.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
|
||||
// By: Campredon <https://github.com/fdecampredon/>
|
||||
|
||||
// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code):
|
||||
// - https://github.com/borisyankov/DefinitelyTyped/issues/1563
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// TODO fix remaining TODO annotations in both definition and test
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
|
||||
*/
|
||||
constructor(callback: (resolve: (thenable: Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
|
||||
constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
|
||||
|
||||
/**
|
||||
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
|
||||
*/
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
|
||||
*
|
||||
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
|
||||
*/
|
||||
error<U>(onReject: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
error<U>(onReject: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
finally(handler: (value: R) => R): Promise<R>;
|
||||
finally(handler: (value: R) => void): Promise<R>;
|
||||
|
||||
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
lastly(handler: (value: R) => R): Promise<R>;
|
||||
lastly(handler: (value: R) => void): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
*/
|
||||
bind(thisArg: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
*/
|
||||
progressed(handler: (note: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
delay(ms: number): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
|
||||
*
|
||||
* You may specify a custom error message with the `message` parameter.
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<R>;
|
||||
|
||||
/**
|
||||
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
|
||||
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
|
||||
*/
|
||||
nodeify(callback: (err: any, value?: R) => void): Promise<R>;
|
||||
nodeify(...sink: any[]): void;
|
||||
|
||||
/**
|
||||
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
|
||||
*/
|
||||
cancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
|
||||
*
|
||||
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
|
||||
*
|
||||
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
|
||||
*
|
||||
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
|
||||
*/
|
||||
// TODO what to do with this?
|
||||
cancel<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
|
||||
*/
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Create an uncancellable promise based on this promise.
|
||||
*/
|
||||
uncancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* See if this promise can be cancelled.
|
||||
*/
|
||||
isCancellable(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been fulfilled.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been rejected.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is still defer.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is resolved -> either fulfilled or rejected.
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
inspect(): Promise.Inspection<R>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName].call(obj, arg...);
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
call(propertyName: string, ...args: any[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName];
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
// TODO find way to fix get()
|
||||
// get<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
|
||||
*
|
||||
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
return(): Promise<any>;
|
||||
thenReturn(): Promise<any>;
|
||||
return<U>(value: U): Promise<U>;
|
||||
thenReturn<U>(value: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.return()`.
|
||||
*
|
||||
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
throw(reason: Error): Promise<R>;
|
||||
thenThrow(reason: Error): Promise<R>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
|
||||
/**
|
||||
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
|
||||
*/
|
||||
// TODO how to model instance.spread()? like Q?
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => U): Promise<U>;
|
||||
/*
|
||||
// TODO or something like this?
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => U): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
|
||||
*/
|
||||
/**
|
||||
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
all<U>(): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO how to model instance.props()?
|
||||
props(): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
settle<U>(): Promise<Promise.Inspection<U>[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
any<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
some<U>(count: number): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
race<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U[]>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
*
|
||||
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
|
||||
*
|
||||
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
static try<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static try<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static attempt<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static attempt<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
|
||||
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
|
||||
*/
|
||||
static method(fn: Function): Function;
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
|
||||
*/
|
||||
static resolve(): Promise<void>;
|
||||
static resolve<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
static resolve<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that is rejected with the given `reason`.
|
||||
*/
|
||||
static reject(reason: any): Promise<any>;
|
||||
static reject<R>(reason: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
|
||||
*/
|
||||
static defer<R>(): Promise.Resolver<R>;
|
||||
|
||||
/**
|
||||
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
|
||||
*/
|
||||
static cast<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
static cast<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
|
||||
*/
|
||||
static bind(thisArg: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* See if `value` is a trusted Promise.
|
||||
*/
|
||||
static is(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
|
||||
*/
|
||||
static longStackTraces(): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
static delay<R>(value: Promise.Thenable<R>, ms: number): Promise<R>;
|
||||
static delay<R>(value: R, ms: number): Promise<R>;
|
||||
static delay(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
|
||||
*
|
||||
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
|
||||
*
|
||||
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
|
||||
*/
|
||||
// TODO how to model promisify?
|
||||
static promisify(nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
/**
|
||||
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
// TODO fix coroutine GeneratorFunction
|
||||
static coroutine<R>(generatorFunction: Function): Function;
|
||||
|
||||
/**
|
||||
* Spawn a coroutine which may yield promises 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.
|
||||
*/
|
||||
// TODO fix spawn GeneratorFunction
|
||||
static spawn<R>(generatorFunction: Function): Promise<R>;
|
||||
|
||||
/**
|
||||
* This is relevant to browser environments with no module loader.
|
||||
*
|
||||
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
|
||||
*/
|
||||
static noConflict(): typeof Promise;
|
||||
|
||||
/**
|
||||
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
|
||||
*
|
||||
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
|
||||
*/
|
||||
static onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
// promise of array with promises of value
|
||||
static all<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
|
||||
// promise of array with values
|
||||
static all<R>(values: Promise.Thenable<R[]>): Promise<R[]>;
|
||||
// array with promises of value
|
||||
static all<R>(values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
// array with values
|
||||
static all<R>(values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
|
||||
*
|
||||
* *The original object is not modified.*
|
||||
*/
|
||||
// TODO verify this is correct
|
||||
// trusted promise for object
|
||||
static props(object: Promise<Object>): Promise<Object>;
|
||||
// object
|
||||
static props(object: Object): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
|
||||
*
|
||||
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static settle<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// promise of array with values
|
||||
static settle<R>(values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// array with promises of value
|
||||
static settle<R>(values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
|
||||
// array with values
|
||||
static settle<R>(values: R[]): Promise<Promise.Inspection<R>[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static any<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
static any<R>(values: Promise.Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
static any<R>(values: Promise.Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
static any<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
|
||||
*
|
||||
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static race<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
static race<R>(values: Promise.Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
static race<R>(values: Promise.Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
static race<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
|
||||
*
|
||||
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static some<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
|
||||
// promise of array with values
|
||||
static some<R>(values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
|
||||
// array with promises of value
|
||||
static some<R>(values: Promise.Thenable<R>[], count: number): Promise<R[]>;
|
||||
// array with values
|
||||
static some<R>(values: R[], count: number): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
|
||||
*/
|
||||
// variadic array with promises of value
|
||||
static join<R>(...values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
// variadic array with values
|
||||
static join<R>(...values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*
|
||||
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// promise of array with values
|
||||
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with promises of value
|
||||
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with values
|
||||
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
|
||||
*
|
||||
* *The original array is not modified.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// promise of array with values
|
||||
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with promises of value
|
||||
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with values
|
||||
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
export interface RangeError extends Error {
|
||||
}
|
||||
export interface CancellationError extends Error {
|
||||
}
|
||||
export interface TimeoutError extends Error {
|
||||
}
|
||||
export interface TypeError extends Error {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
|
||||
}
|
||||
|
||||
export interface Resolver<R> {
|
||||
/**
|
||||
* Returns a reference to the controlled promise that can be passed to clients.
|
||||
*/
|
||||
promise: Promise<R>;
|
||||
|
||||
/**
|
||||
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
|
||||
*/
|
||||
resolve(value: R): void;
|
||||
resolve(): void;
|
||||
|
||||
/**
|
||||
* Reject the underlying promise with `reason` as the rejection reason.
|
||||
*/
|
||||
reject(reason: any): void;
|
||||
|
||||
/**
|
||||
* Progress the underlying promise with `value` as the progression value.
|
||||
*/
|
||||
progress(value: any): void;
|
||||
|
||||
/**
|
||||
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
|
||||
*
|
||||
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
|
||||
*/
|
||||
// TODO specify resolver callback
|
||||
callback: (err: any, value: R, ...values: R[]) => void;
|
||||
}
|
||||
|
||||
export interface Inspection<R> {
|
||||
/**
|
||||
* See if the underlying promise was fulfilled at the creation time of this inspection object.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was rejected at the creation time of this inspection object.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was defer at the creation time of this inspection object.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): R;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
error(): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
+44
-29
@@ -20,6 +20,7 @@ var exp: RegExp;
|
||||
var anyArr: any[];
|
||||
var strArr: string[];
|
||||
var numArr: number[];
|
||||
var voidVar: void;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -199,7 +200,7 @@ bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.error();
|
||||
x = fooInspection.reason();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -244,9 +245,15 @@ barProm = fooProm.caught((reason: any) => {
|
||||
barProm = fooProm.catch(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -256,36 +263,28 @@ barProm = fooProm.error((reason: any) => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
fooProm = fooProm.finally(() => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -294,40 +293,56 @@ fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
return voidThen;
|
||||
});
|
||||
fooProm = fooProm.tap(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
|
||||
Vendored
+52
-12
@@ -16,7 +16,7 @@
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
|
||||
*/
|
||||
@@ -72,13 +72,11 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
finally(handler: (value: R) => R): Promise<R>;
|
||||
finally(handler: (value: R) => void): Promise<R>;
|
||||
finally<U>(handler: () => Promise.Thenable<U>): Promise<R>;
|
||||
finally<U>(handler: () => U): Promise<R>;
|
||||
|
||||
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
lastly(handler: (value: R) => R): Promise<R>;
|
||||
lastly(handler: (value: R) => void): Promise<R>;
|
||||
lastly<U>(handler: () => Promise.Thenable<U>): Promise<R>;
|
||||
lastly<U>(handler: () => U): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
@@ -88,10 +86,16 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
|
||||
|
||||
/**
|
||||
* Like `.finally()`, but not called for rejections.
|
||||
*/
|
||||
tap<U>(onFulFill: (value: R) => Promise.Thenable<U>): Promise<R>;
|
||||
tap<U>(onFulfill: (value: R) => U): Promise<R>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
@@ -172,6 +176,20 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): R;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
@@ -594,6 +612,20 @@ declare module Promise {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
export interface OperationalError extends Error {
|
||||
}
|
||||
|
||||
// Ideally, we'd define e.g. "export class RangeError extends Error {}",
|
||||
// but as Error is defined as an interface (not a class), TypeScript doesn't
|
||||
// allow extending Error, only implementing it.
|
||||
// However, if we want to catch() only a specific error type, we need to pass
|
||||
// a constructor function to it. So, as a workaround, we define them here as such.
|
||||
export function RangeError(): RangeError;
|
||||
export function CancellationError(): CancellationError;
|
||||
export function TimeoutError(): TimeoutError;
|
||||
export function TypeError(): TypeError;
|
||||
export function RejectionError(): RejectionError;
|
||||
export function OperationalError(): OperationalError;
|
||||
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
@@ -661,8 +693,16 @@ declare module Promise {
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
error(): any;
|
||||
reason(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes how bluebird schedules calls a-synchronously.
|
||||
*
|
||||
* @param scheduler Should be a function that asynchronously schedules
|
||||
* the calling of the passed in function
|
||||
*/
|
||||
export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/// <reference path="change-case.d.ts"/>
|
||||
|
||||
import changeCase = require("change-case");
|
||||
|
||||
var s: string;
|
||||
var b: boolean;
|
||||
|
||||
s = changeCase.dot(s);
|
||||
s = changeCase.dotCase(s);
|
||||
s = changeCase.swap(s);
|
||||
s = changeCase.swapCase(s);
|
||||
s = changeCase.path(s);
|
||||
s = changeCase.pathCase(s);
|
||||
s = changeCase.upper(s);
|
||||
s = changeCase.upperCase(s);
|
||||
s = changeCase.lower(s);
|
||||
s = changeCase.lowerCase(s);
|
||||
s = changeCase.camel(s);
|
||||
s = changeCase.camelCase(s);
|
||||
s = changeCase.snake(s);
|
||||
s = changeCase.snakeCase(s);
|
||||
s = changeCase.title(s);
|
||||
s = changeCase.titleCase(s);
|
||||
s = changeCase.param(s);
|
||||
s = changeCase.paramCase(s);
|
||||
s = changeCase.pascal(s);
|
||||
s = changeCase.pascalCase(s);
|
||||
s = changeCase.constant(s);
|
||||
s = changeCase.constantCase(s);
|
||||
s = changeCase.sentence(s);
|
||||
s = changeCase.sentenceCase(s);
|
||||
b = changeCase.isUpper(s);
|
||||
b = changeCase.isUpperCase(s);
|
||||
b = changeCase.isLower(s);
|
||||
b = changeCase.isLowerCase(s);
|
||||
s = changeCase.ucFirst(s);
|
||||
s = changeCase.upperCaseFirst(s);
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions for change-case
|
||||
// Project: https://github.com/blakeembrey/change-case
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "change-case" {
|
||||
function dot(s: string): string;
|
||||
function dotCase(s: string): string;
|
||||
function swap(s: string): string;
|
||||
function swapCase(s: string): string;
|
||||
function path(s: string): string;
|
||||
function pathCase(s: string): string;
|
||||
function upper(s: string): string;
|
||||
function upperCase(s: string): string;
|
||||
function lower(s: string): string;
|
||||
function lowerCase(s: string): string;
|
||||
function camel(s: string): string;
|
||||
function camelCase(s: string): string;
|
||||
function snake(s: string): string;
|
||||
function snakeCase(s: string): string;
|
||||
function title(s: string): string;
|
||||
function titleCase(s: string): string;
|
||||
function param(s: string): string;
|
||||
function paramCase(s: string): string;
|
||||
function pascal(s: string): string;
|
||||
function pascalCase(s: string): string;
|
||||
function constant(s: string): string;
|
||||
function constantCase(s: string): string;
|
||||
function sentence(s: string): string;
|
||||
function sentenceCase(s: string): string;
|
||||
function isUpper(s: string): boolean;
|
||||
function isUpperCase(s: string): boolean;
|
||||
function isLower(s: string): boolean;
|
||||
function isLowerCase(s: string): boolean;
|
||||
function ucFirst(s: string): string;
|
||||
function upperCaseFirst(s: string): string;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="content-type.d.ts" />
|
||||
|
||||
import MediaType = require('content-type');
|
||||
|
||||
// https://github.com/deoxxa/content-type/blob/master/README.md
|
||||
function new_test(): void {
|
||||
var p = new MediaType('text/html;level=1;q=0.5');
|
||||
p.q === 0.5;
|
||||
p.params.level === "1";
|
||||
|
||||
var q = new MediaType('application/json', { profile: 'http://example.com/schema.json' });
|
||||
q.type === "application/json";
|
||||
q.params.profile === "http://example.com/schema.json";
|
||||
|
||||
q.q = 1;
|
||||
q.toString() === 'application/json;q=1;profile="http://example.com/schema.json"';
|
||||
}
|
||||
|
||||
function mediaCmp_test(): void {
|
||||
MediaType.mediaCmp(MediaType.parseMedia('text/html'), MediaType.parseMedia('text/html')) === 0;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('*/*'), MediaType.parseMedia('text/html')) === 1;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('text/html;level=1'), MediaType.parseMedia('text/html')) === -1;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('application/json;profile="v1.json"'), MediaType.parseMedia('application/json;profile="v2.json"')) === null;
|
||||
}
|
||||
|
||||
// https://github.com/deoxxa/content-type/blob/master/example.js
|
||||
function example(): void {
|
||||
var representations = [
|
||||
'application/json',
|
||||
'text/html',
|
||||
'application/json;profile="schema.json"',
|
||||
'application/json;profile="different.json"',
|
||||
];
|
||||
|
||||
var accept = [
|
||||
'text/html;q=0.50',
|
||||
'*/*;q=0.01',
|
||||
'application/json;profile=different.json',
|
||||
'application/json;profile="a,b;c.json?d=1;f=2";q=0.2',
|
||||
];
|
||||
|
||||
console.log('Formats:\n\t' + representations.map(MediaType.parseMedia).join('\n\t'));
|
||||
|
||||
console.log('Accept:\n\t' + accept.map(MediaType.parseMedia).join('\n\t'));
|
||||
|
||||
console.log('Selected:', (MediaType.select(representations.map(MediaType.parseMedia), accept.map(MediaType.parseMedia)) || 'None').toString());
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for content-type v0.0.1
|
||||
// Project: https://github.com/deoxxa/content-type
|
||||
// Definitions by: Pine Mizune <https://github.com/pine613>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module ContentType {
|
||||
interface MediaType {
|
||||
type: string;
|
||||
q?: number;
|
||||
params: any;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface SelectOptions {
|
||||
sortAvailable?: boolean;
|
||||
sortAccepted?: boolean;
|
||||
}
|
||||
|
||||
interface MediaTypeStatic {
|
||||
new (s: string, p?: any): MediaType;
|
||||
parseMedia(type: string): MediaType;
|
||||
splitQuotedString(str: string, delimiter?: string, quote?: string): string[];
|
||||
splitContentTypes(str: string): string[];
|
||||
select(availableTypes: MediaType[], acceptedTypes: MediaType[], options?: SelectOptions): string;
|
||||
mediaCmp(a: MediaType, b: MediaType): number;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "content-type" {
|
||||
var x: ContentType.MediaTypeStatic;
|
||||
export = x;
|
||||
}
|
||||
@@ -227,4 +227,6 @@ function test_methods() {
|
||||
maxlength: 5
|
||||
}
|
||||
});
|
||||
var invalidElements: HTMLElement[] = validator.invalidElements();
|
||||
var validElements: HTMLElement[] = validator.validElements();
|
||||
}
|
||||
|
||||
+2
@@ -197,6 +197,7 @@ interface Validator
|
||||
* @param template The string to format.
|
||||
*/
|
||||
format(template: string, ...arguments: string[]): string;
|
||||
invalidElements(): HTMLElement[];
|
||||
/**
|
||||
* Returns the number of invalid fields.
|
||||
*/
|
||||
@@ -220,6 +221,7 @@ interface Validator
|
||||
showErrors(errors: any): void;
|
||||
hideErrors(): void;
|
||||
valid(): boolean;
|
||||
validElements(): HTMLElement[];
|
||||
size(): number;
|
||||
|
||||
errorMap: ErrorDictionary;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="lscache.d.ts" />
|
||||
|
||||
// Copied examples directly from lscache github site with slight modifications
|
||||
|
||||
lscache.set('greeting', 'Hello World!', 2);
|
||||
|
||||
alert(lscache.get('greeting'));
|
||||
|
||||
lscache.remove('greeting');
|
||||
|
||||
lscache.set('data', { 'name': 'Pamela', 'age': 26 }, 2);
|
||||
|
||||
alert(lscache.get('data').name);
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for lscache v1.0.2
|
||||
// Project: https://github.com/pamelafox/lscache
|
||||
// Definitions by: Chris Martinez <https://github.com/Chris-Martinezz>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface LSCache {
|
||||
|
||||
set(key: string, value: any, time?: number): void;
|
||||
get(key: string): any;
|
||||
remove(key: string): void;
|
||||
}
|
||||
|
||||
declare var lscache: LSCache;
|
||||
@@ -0,0 +1,63 @@
|
||||
// Type definitions for minilog v2
|
||||
// Project: https://github.com/mixu/minilog
|
||||
// Definitions by: Guido <http://guido.io>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="minilog.d.ts"/>
|
||||
|
||||
|
||||
//Following are example snippets from mixu.net/minilog
|
||||
|
||||
var log = Minilog('app');
|
||||
Minilog.enable();
|
||||
|
||||
log
|
||||
.debug('debug message')
|
||||
.info('info message')
|
||||
.warn('warning')
|
||||
.error('this is an error message');
|
||||
|
||||
Minilog.pipe(Minilog.backends.console.formatWithStack)
|
||||
.pipe(Minilog.backends.console);
|
||||
|
||||
|
||||
Minilog
|
||||
// formatter
|
||||
.pipe(Minilog.backends.console.formatClean)
|
||||
// backend
|
||||
.pipe(Minilog.backends.console);
|
||||
|
||||
|
||||
Minilog.pipe(Minilog.suggest) // filter
|
||||
.pipe(Minilog.defaultFormatter) // formatter
|
||||
.pipe(Minilog.defaultBackend); // backend - e.g. the console
|
||||
|
||||
Minilog.suggest.deny(/mymodule\/.*/, 'warn');
|
||||
|
||||
Minilog
|
||||
.suggest
|
||||
.clear()
|
||||
.deny('foo', 'warn');
|
||||
Minilog.enable();
|
||||
|
||||
Minilog.suggest.defaultResult = false;
|
||||
Minilog
|
||||
.suggest
|
||||
.clear()
|
||||
.allow('bar', 'info');
|
||||
Minilog.enable();
|
||||
|
||||
|
||||
var myFilter = new Minilog.Filter();
|
||||
// allow any logs from the namespace/module "foo", level >= 'info
|
||||
myFilter.allow('foo', 'debug');
|
||||
// deny any logs where the module name matches "bar.*", level < 'warn'
|
||||
// e.g. only let through "warn" and "error"
|
||||
myFilter.deny(new RegExp('bar.*', 'warn'));
|
||||
|
||||
// now, create a custom pipe
|
||||
Minilog.pipe(myFilter)
|
||||
.pipe(Minilog.defaultFormatter)
|
||||
.pipe(Minilog.defaultBackend);
|
||||
|
||||
|
||||
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
// Type definitions for minilog v2
|
||||
// Project: https://github.com/mixu/minilog
|
||||
// Definitions by: Guido <http://guido.io>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
//These type definitions are not complete, although basic usage should be typed.
|
||||
interface Minilog {
|
||||
debug(msg: any): Minilog;
|
||||
info(msg: any): Minilog;
|
||||
log(msg: any): Minilog;
|
||||
warn(msg: any): Minilog;
|
||||
error(msg: any): Minilog;
|
||||
}
|
||||
|
||||
declare function Minilog(namespace: string): Minilog;
|
||||
|
||||
declare module Minilog {
|
||||
export function enable(): Minilog;
|
||||
export function disable() : Minilog;
|
||||
export function pipe(dest: any): Transform;
|
||||
|
||||
export var suggest: Filter;
|
||||
export var backends: Minilog.MinilogBackends;
|
||||
|
||||
export var defaultBackend: any;
|
||||
export var defaultFormatter: string;
|
||||
|
||||
|
||||
export class Filter extends Transform{
|
||||
|
||||
/**
|
||||
* Adds an entry to the whitelist
|
||||
* Returns this filter
|
||||
*/
|
||||
allow(name: any, level?: any): Filter;
|
||||
/**
|
||||
* Adds an entry to the blacklist
|
||||
* Returns this filter
|
||||
*/
|
||||
deny(name: any, level?: any): Filter;
|
||||
/**
|
||||
* Empties the whitelist and blacklist
|
||||
* Returns this filter
|
||||
*/
|
||||
clear(): Filter;
|
||||
|
||||
test(name:any, level:any): boolean;
|
||||
|
||||
/**
|
||||
* specifies the behavior when a log line doesn't match either the whitelist or the blacklist.
|
||||
The default is true (= "allow by default") - lines that do not match the whitelist or the blacklist are not filtered (e.g. ).
|
||||
If you want to flip the default so that lines are filtered unless they are on the whitelist, set this to false (= "deny by default").
|
||||
*/
|
||||
defaultResult: boolean;
|
||||
|
||||
/**
|
||||
* controls whether the filter is enabled. Default: true
|
||||
*/
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface MinilogBackends {
|
||||
array: any;
|
||||
browser: any;
|
||||
console: Console;
|
||||
localstorage: any;
|
||||
jQuery: any;
|
||||
}
|
||||
|
||||
export class Console extends Transform{
|
||||
|
||||
/**
|
||||
* List of available formatters
|
||||
*/
|
||||
formatters: string[];
|
||||
|
||||
//Only available on client
|
||||
color: Transform;
|
||||
minilog: Transform;
|
||||
|
||||
//Only available on backend
|
||||
formatClean: Transform;
|
||||
formatColor: Transform;
|
||||
formatNpm: Transform;
|
||||
formatLearnboost: Transform;
|
||||
formatMinilog: Transform;
|
||||
formatWithStack: Transform;
|
||||
}
|
||||
|
||||
export class Transform {
|
||||
write(name: any, level: any, args: any): void;
|
||||
pipe(dest: any): any;
|
||||
unpipe(from: any): Transform;
|
||||
mixin(dest: any): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,6 +91,7 @@ function stream_readable_pipe_test() {
|
||||
var z = zlib.createGzip();
|
||||
var w = fs.createWriteStream('file.txt.gz');
|
||||
r.pipe(z).pipe(w);
|
||||
r.close();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+13
-9
@@ -721,8 +721,8 @@ declare module "net" {
|
||||
setKeepAlive(enable?: boolean, initialDelay?: number): void;
|
||||
address(): { port: number; family: string; address: string; };
|
||||
unref(): void;
|
||||
ref(): void;
|
||||
|
||||
ref(): void;
|
||||
|
||||
remoteAddress: string;
|
||||
remotePort: number;
|
||||
bytesRead: number;
|
||||
@@ -770,13 +770,13 @@ declare module "dgram" {
|
||||
port: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
|
||||
interface AddressInfo {
|
||||
address: string;
|
||||
family: string;
|
||||
port: number;
|
||||
address: string;
|
||||
family: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
|
||||
export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
|
||||
interface Socket extends events.EventEmitter {
|
||||
@@ -823,8 +823,12 @@ declare module "fs" {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface ReadStream extends stream.Readable {}
|
||||
export interface WriteStream extends stream.Writable {}
|
||||
export interface ReadStream extends stream.Readable {
|
||||
close(): void;
|
||||
}
|
||||
export interface WriteStream extends stream.Writable {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
|
||||
export function renameSync(oldPath: string, newPath: string): void;
|
||||
|
||||
@@ -20,10 +20,9 @@ var loose:boolean;
|
||||
str = mod.valid(str);
|
||||
|
||||
str = mod.valid(str, loose);
|
||||
//TODO maybe add an enum for release?
|
||||
str = mod.inc(str, str, loose);
|
||||
|
||||
//Comparison
|
||||
// Comparison
|
||||
bool = mod.gt(v1, v2, loose);
|
||||
bool = mod.gte(v1, v2, loose);
|
||||
bool = mod.lt(v1, v2, loose);
|
||||
@@ -34,9 +33,9 @@ bool = mod.cmp(v1, x, v2, loose);
|
||||
num = mod.compare(v1, v2, loose);
|
||||
num = mod.rcompare(v1, v2, loose);
|
||||
|
||||
//Ranges
|
||||
// Ranges
|
||||
str = mod.validRange(str, loose);
|
||||
str = mod.satisfies(version, str, loose);
|
||||
bool = mod.satisfies(version, str, loose);
|
||||
str = mod.maxSatisfying(versions, str, loose);
|
||||
bool = mod.gtr(version, str, loose);
|
||||
bool = mod.ltr(version, str, loose);
|
||||
|
||||
Vendored
+99
-49
@@ -4,72 +4,122 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module SemVerModule {
|
||||
/**
|
||||
* Return the parsed version, or null if it's not valid.
|
||||
*/
|
||||
function valid(v: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||
*/
|
||||
function inc(v: string, release: string, loose?: boolean): string;
|
||||
|
||||
function valid(v:string, loose?:boolean):string; // Return the parsed version, or null if it's not valid.
|
||||
//TODO maybe add an enum for release?
|
||||
function inc(v:string, release:string, loose?:boolean):string; // Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||
// Comparison
|
||||
/**
|
||||
* v1 > v2
|
||||
*/
|
||||
function gt(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 >= v2
|
||||
*/
|
||||
function gte(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 < v2
|
||||
*/
|
||||
function lt(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 <= v2
|
||||
*/
|
||||
function lte(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||
*/
|
||||
function eq(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* v1 != v2 The opposite of eq.
|
||||
*/
|
||||
function neq(v1: string, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Pass in a comparison string, and it'll call the corresponding semver comparison function. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
|
||||
*/
|
||||
function cmp(v1: string, comparator: any, v2: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||
*/
|
||||
function compare(v1: string, v2: string, loose?: boolean): number;
|
||||
/**
|
||||
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||
*/
|
||||
function rcompare(v1: string, v2: string, loose?: boolean): number;
|
||||
|
||||
//Comparison
|
||||
function gt(v1:string, v2:string, loose?:boolean):boolean; // v1 > v2
|
||||
function gte(v1:string, v2:string, loose?:boolean):boolean; // v1 >= v2
|
||||
function lt(v1:string, v2:string, loose?:boolean):boolean; // v1 < v2
|
||||
function lte(v1:string, v2:string, loose?:boolean):boolean; // v1 <= v2
|
||||
function eq(v1:string, v2:string, loose?:boolean):boolean; // v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||
function neq(v1:string, v2:string, loose?:boolean):boolean; // v1 != v2 The opposite of eq.
|
||||
function cmp(v1:string, comparator:any, v2:string, loose?:boolean):boolean; // Pass in a comparison string, and it'll call the corresponding function above. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided.
|
||||
function compare(v1:string, v2:string, loose?:boolean):number; // Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||
function rcompare(v1:string, v2:string, loose?:boolean):number; // The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||
|
||||
//Ranges
|
||||
function validRange(range:string, loose?:boolean):string; // Return the valid range or null if it's not valid
|
||||
function satisfies(version:string, range:string, loose?:boolean):string; // Return true if the version satisfies the range.
|
||||
function maxSatisfying(versions:string[], range:string, loose?:boolean):string; // Return the highest version in the list that satisfies the range, or null if none of them do.
|
||||
function gtr(version:string, range:string, loose?:boolean):boolean; // Return true if version is greater than all the versions possible in the range.
|
||||
function ltr(version:string, range:string, loose?:boolean):boolean; // Return true if version is less than all the versions possible in the range.
|
||||
function outside(version:string, range:string, hilo:string, loose?:boolean):boolean; // Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
// Ranges
|
||||
/**
|
||||
* Return the valid range or null if it's not valid
|
||||
*/
|
||||
function validRange(range: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return true if the version satisfies the range.
|
||||
*/
|
||||
function satisfies(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return the highest version in the list that satisfies the range, or null if none of them do.
|
||||
*/
|
||||
function maxSatisfying(versions: string[], range: string, loose?: boolean): string;
|
||||
/**
|
||||
* Return true if version is greater than all the versions possible in the range.
|
||||
*/
|
||||
function gtr(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return true if version is less than all the versions possible in the range.
|
||||
*/
|
||||
function ltr(version: string, range: string, loose?: boolean): boolean;
|
||||
/**
|
||||
* Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
*/
|
||||
function outside(version: string, range: string, hilo: string, loose?: boolean): boolean;
|
||||
|
||||
class SemVerBase {
|
||||
raw:string;
|
||||
loose:boolean;
|
||||
format():string;
|
||||
inspect():string;
|
||||
toString():string;
|
||||
raw: string;
|
||||
loose: boolean;
|
||||
format(): string;
|
||||
inspect(): string;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
class SemVer extends SemVerBase {
|
||||
constructor(version:string, loose?:boolean);
|
||||
class SemVer extends SemVerBase {
|
||||
constructor(version: string, loose?: boolean);
|
||||
|
||||
major:number;
|
||||
minor:number;
|
||||
patch:number;
|
||||
version:string;
|
||||
build:string[];
|
||||
prerelease:string[];
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
version: string;
|
||||
build: string[];
|
||||
prerelease: string[];
|
||||
|
||||
compare(other:SemVer):number;
|
||||
compareMain(other:SemVer):number;
|
||||
comparePre(other:SemVer):number;
|
||||
inc(release:string):SemVer;
|
||||
compare(other:SemVer): number;
|
||||
compareMain(other:SemVer): number;
|
||||
comparePre(other:SemVer): number;
|
||||
inc(release: string): SemVer;
|
||||
}
|
||||
|
||||
class Comparator extends SemVerBase {
|
||||
constructor(comp:string, loose?:boolean);
|
||||
constructor(comp: string, loose?: boolean);
|
||||
|
||||
semver:SemVer;
|
||||
operator:string;
|
||||
value:boolean;
|
||||
parse(comp:string) :void;
|
||||
test(version:SemVer):boolean;
|
||||
semver: SemVer;
|
||||
operator: string;
|
||||
value: boolean;
|
||||
parse(comp: string): void;
|
||||
test(version:SemVer): boolean;
|
||||
}
|
||||
|
||||
class Range extends SemVerBase {
|
||||
constructor(range:string, loose?:boolean);
|
||||
constructor(range: string, loose?: boolean);
|
||||
|
||||
set:Comparator[][];
|
||||
parseRange(range:string):Comparator[];
|
||||
test(version:SemVer):boolean;
|
||||
set: Comparator[][];
|
||||
parseRange(range: string): Comparator[];
|
||||
test(version: SemVer): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "semver" {
|
||||
export = SemVerModule;
|
||||
export = SemVerModule;
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Test suite created by Maxime LUCE <https://github.com/SomaticIT>
|
||||
*
|
||||
* Created by using code samples from https://github.com/npm/node-tar.
|
||||
*/
|
||||
* Test suite created by Maxime LUCE <https://github.com/SomaticIT>
|
||||
*
|
||||
* Created by using code samples from https://github.com/npm/node-tar.
|
||||
*/
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="tar.d.ts" />
|
||||
@@ -26,3 +26,6 @@ readStream.pipe(extract);
|
||||
extract.on("entry", (entry: any) => {
|
||||
|
||||
});
|
||||
|
||||
var packStream: tar.PackStream = tar.Pack();
|
||||
packStream = tar.Pack({ path: 'test' });
|
||||
|
||||
Vendored
+27
-6
@@ -2,13 +2,14 @@
|
||||
// Project: https://github.com/npm/node-tar
|
||||
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// TODO: When/if typings for [fstream](https://github.com/npm/fstream) are written, refactor this typing to use it for the various streams.
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "tar" {
|
||||
import stream = require("stream");
|
||||
|
||||
//#region Interfaces
|
||||
// #region Interfaces
|
||||
|
||||
export interface HeaderProperties {
|
||||
path?: string;
|
||||
@@ -64,9 +65,9 @@ declare module "tar" {
|
||||
export interface ExtractStream extends ParseStream {
|
||||
}
|
||||
|
||||
//#endregion
|
||||
// #endregion
|
||||
|
||||
//#region Enums
|
||||
// #region Enums
|
||||
|
||||
export var fields: {
|
||||
path: number;
|
||||
@@ -198,11 +199,31 @@ declare module "tar" {
|
||||
|
||||
//#region Global Methods
|
||||
|
||||
/**
|
||||
* Returns a writable stream. Write tar data to it and it will emit entry events for each entry parsed from the tarball. This is used by tar.Extract.
|
||||
*/
|
||||
export function Parse(): ParseStream;
|
||||
|
||||
export function Pack(props: HeaderProperties): PackStream;
|
||||
|
||||
/**
|
||||
* Returns a through stream. Use fstream to write files into the pack stream and you will receive tar archive data from the pack stream.
|
||||
* This only works with directories, it does not work with individual files.
|
||||
* The optional properties object are used to set properties in the tar 'Global Extended Header'.
|
||||
*/
|
||||
export function Pack(props?: HeaderProperties): PackStream;
|
||||
/**
|
||||
* Returns a through stream. Write tar data to the stream and the files in the tarball will be extracted onto the filesystem.
|
||||
*/
|
||||
export function Extract(path: string): ExtractStream;
|
||||
/**
|
||||
* Returns a through stream. Write tar data to the stream and the files in the tarball will be extracted onto the filesystem.
|
||||
* options can be:
|
||||
* ```
|
||||
* {
|
||||
* path: '/path/to/extract/tar/into',
|
||||
* strip: 0, // how many path segments to strip from the root when extracting
|
||||
* }
|
||||
* ```
|
||||
* options also get passed to the fstream.Writer instance that tar uses internally.
|
||||
*/
|
||||
export function Extract(opts: ExtractOptions): ExtractStream;
|
||||
|
||||
//#endregion
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
/// <reference path="./three.d.ts" />
|
||||
|
||||
declare module THREE {
|
||||
class TrackballControls {
|
||||
class TrackballControls extends EventDispatcher {
|
||||
constructor(object:Camera, domElement?:HTMLElement);
|
||||
|
||||
object:Camera;
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/// <reference path="./validator.d.ts" />
|
||||
|
||||
import validator = require("validator");
|
||||
|
||||
|
||||
validator.extend("isTest", function(str) {
|
||||
return !str;
|
||||
});
|
||||
|
||||
validator.equals("abc", "Abc");
|
||||
|
||||
validator.contains("foo", "foobar");
|
||||
|
||||
validator.matches("foobar", "foo/i");
|
||||
|
||||
validator.isEmail("sample");
|
||||
|
||||
validator.isURL("sample");
|
||||
|
||||
validator.isFQDN("sample");
|
||||
|
||||
validator.isIP("sample");
|
||||
|
||||
validator.isAlpha("sample");
|
||||
|
||||
validator.isNumeric("sample");
|
||||
|
||||
validator.isAlphanumeric("sample");
|
||||
|
||||
validator.isBase64("sample");
|
||||
|
||||
validator.isHexadecimal("sample");
|
||||
|
||||
validator.isHexColor("sample");
|
||||
|
||||
validator.isLowercase("sample");
|
||||
|
||||
validator.isUppercase("sample");
|
||||
|
||||
validator.isInt("sample");
|
||||
|
||||
validator.isFloat("sample");
|
||||
|
||||
validator.isDivisibleBy("sample", 2);
|
||||
|
||||
validator.isNull("sample");
|
||||
|
||||
validator.isLength("sample", 3, 5);
|
||||
|
||||
validator.isByteLength("sample", 3);
|
||||
|
||||
validator.isUUID("sample");
|
||||
|
||||
validator.isDate("sample");
|
||||
|
||||
validator.isAfter("sample");
|
||||
|
||||
validator.isBefore("sample");
|
||||
|
||||
validator.isIn("sample", []);
|
||||
|
||||
validator.isCreditCard("sample");
|
||||
|
||||
validator.isISBN("sample");
|
||||
|
||||
validator.isJSON("sample");
|
||||
|
||||
validator.isMultibyte("sample");
|
||||
|
||||
validator.isAscii("sample");
|
||||
|
||||
validator.isFullWidth("sample");
|
||||
|
||||
validator.isHalfWidth("sample");
|
||||
|
||||
validator.isVariableWidth("sample");
|
||||
|
||||
validator.isSurrogatePair("sample");
|
||||
|
||||
validator.isMongoId("sample");
|
||||
|
||||
validator.toString(123);
|
||||
|
||||
validator.toDate(1225);
|
||||
|
||||
validator.toFloat('011');
|
||||
|
||||
validator.toInt('aa');
|
||||
|
||||
validator.toBoolean('yes!');
|
||||
|
||||
validator.trim(' triming ');
|
||||
|
||||
validator.ltrim(' triming ');
|
||||
|
||||
validator.rtrim(' triming ');
|
||||
|
||||
validator.escape('<script>');
|
||||
|
||||
validator.stripLow('\x7Ffoo\x02');
|
||||
|
||||
validator.whitelist('ab', 'abcdef');
|
||||
|
||||
validator.blacklist('abc', 'abcdef');
|
||||
|
||||
validator.normalizeEmail('!');
|
||||
Vendored
+190
@@ -0,0 +1,190 @@
|
||||
// Type definitions for validator.js v3.22.1
|
||||
// Project: https://github.com/chriso/validator.js
|
||||
// Definitions by: tgfjt <https://github.com/tgfjt>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// options for #isURL
|
||||
interface IURLoptions {
|
||||
protocols?: string[]
|
||||
require_tld?: boolean
|
||||
require_protocol?: boolean
|
||||
allow_underscores?: boolean
|
||||
}
|
||||
|
||||
// options for isFQDN
|
||||
interface IFQDNoptions {
|
||||
require_tld?: boolean
|
||||
allow_underscores?: boolean
|
||||
}
|
||||
|
||||
// options for normalizeEmail
|
||||
interface IEmailoptions {
|
||||
lowercase?: boolean
|
||||
}
|
||||
|
||||
// callback type for #extend
|
||||
interface IExtendCallback {
|
||||
(argv: string): any
|
||||
}
|
||||
|
||||
// return function for #extend
|
||||
interface IExtendFunc {
|
||||
(argv: string): boolean
|
||||
}
|
||||
|
||||
interface IValidatorStatic {
|
||||
// add your own validators
|
||||
extend(name: string, fn: IExtendCallback): IExtendFunc;
|
||||
|
||||
// check if the string matches the comparison.
|
||||
equals(str: string, comparison: any): boolean;
|
||||
|
||||
// check if the string contains the seed.
|
||||
contains(str: string, elem: any): boolean;
|
||||
|
||||
// check if string matches the pattern.
|
||||
matches(str: string, pattern: any, modifiers?: string): boolean;
|
||||
|
||||
// check if the string is an email.
|
||||
isEmail(str: string): boolean;
|
||||
|
||||
// check if the string is an URL.
|
||||
isURL(str: string, options?: IURLoptions): boolean;
|
||||
|
||||
// check if the string is a fully qualified domain name (e.g. domain.com).
|
||||
isFQDN(str: string, options?: IFQDNoptions): boolean;
|
||||
|
||||
// check if the string is an IP (version 4 or 6).
|
||||
isIP(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string contains only letters (a-zA-Z).
|
||||
isAlpha(str: string): boolean;
|
||||
|
||||
// check if the string contains only numbers.
|
||||
isNumeric(str: string): boolean;
|
||||
|
||||
// check if the string contains only letters and numbers.
|
||||
isAlphanumeric(str: string): boolean;
|
||||
|
||||
// check if a string is base64 encoded.
|
||||
isBase64(str: string): boolean;
|
||||
|
||||
// check if the string is a hexadecimal number.
|
||||
isHexadecimal(str: string): boolean;
|
||||
|
||||
// check if the string is a hexadecimal color.
|
||||
isHexColor(str: string): boolean;
|
||||
|
||||
// check if the string is lowercase.
|
||||
isLowercase(str: string): boolean;
|
||||
|
||||
// check if the string is uppercase.
|
||||
isUppercase(str: string): boolean;
|
||||
|
||||
// check if the string is an integer.
|
||||
isInt(str: string): boolean;
|
||||
|
||||
// check if the string is a float.
|
||||
isFloat(str: string): boolean;
|
||||
|
||||
// check if the string is a number that's divisible by another.
|
||||
isDivisibleBy(str: string, number: number): boolean;
|
||||
|
||||
// check if the string is null.
|
||||
isNull(str: string): boolean;
|
||||
|
||||
// check if the string's length falls in a range. Note: this function takes into account surrogate pairs.
|
||||
isLength(str: string, min: number, max?: number): boolean;
|
||||
|
||||
// check if the string's length (in bytes) falls in a range.
|
||||
isByteLength(str: string, min: number, max?: number): boolean;
|
||||
|
||||
// check if the string is a UUID (version 3, 4 or 5).
|
||||
isUUID(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string is a date.
|
||||
isDate(str: string): boolean;
|
||||
|
||||
// check if the string is a date that's after the specified date (defaults to now).
|
||||
isAfter(str: string, date?: Date): boolean;
|
||||
|
||||
// check if the string is a date that's before the specified date.
|
||||
isBefore(str: string, date?: Date): boolean;
|
||||
|
||||
// check if the string is in a array of allowed values.
|
||||
isIn(str: string, values: any[]): boolean;
|
||||
|
||||
// check if the string is a credit card.
|
||||
isCreditCard(str: string): boolean;
|
||||
|
||||
// check if the string is an ISBN (version 10 or 13).
|
||||
isISBN(str: string, version?: number): boolean;
|
||||
|
||||
// check if the string is valid JSON (note: uses JSON.parse).
|
||||
isJSON(str: string): boolean;
|
||||
|
||||
// check if the string contains one or more multibyte chars.
|
||||
isMultibyte(str: string): boolean;
|
||||
|
||||
// check if the string contains ASCII chars only.
|
||||
isAscii(str: string): boolean;
|
||||
|
||||
// check if the string contains any full-width chars.
|
||||
isFullWidth(str: string): boolean;
|
||||
|
||||
// check if the string contains any half-width chars.
|
||||
isHalfWidth(str: string): boolean;
|
||||
|
||||
// check if the string contains a mixture of full and half-width chars.
|
||||
isVariableWidth(str: string): boolean;
|
||||
|
||||
// check if the string contains any surrogate pairs chars.
|
||||
isSurrogatePair(str: string): boolean;
|
||||
|
||||
// check if the string is a valid hex-encoded representation of a MongoDB ObjectId.
|
||||
isMongoId(str: string): boolean;
|
||||
|
||||
// convert the input to a string.
|
||||
toString(input: any): string;
|
||||
|
||||
// convert the input to a date, or null if the input is not a date.
|
||||
toDate(input: any): any; // Date or null
|
||||
|
||||
// convert the input to a float, or NaN if the input is not a float.
|
||||
toFloat(input:any): number; // number or NaN
|
||||
|
||||
// convert the input to an integer, or NaN if the input is not an integer.
|
||||
toInt(input:any, radix?: number): number; // number or NaN
|
||||
|
||||
// convert the input to a boolean.
|
||||
toBoolean(input:any, strict?: boolean): boolean;
|
||||
|
||||
// trim characters (whitespace by default) from both sides of the input.
|
||||
trim(input: any, chars?: string): string;
|
||||
|
||||
// trim characters from the left-side of the input.
|
||||
ltrim(input: any, chars?: string): string;
|
||||
|
||||
// trim characters from the right-side of the input.
|
||||
rtrim(input: any, chars?: string): string;
|
||||
|
||||
// replace <, >, &, ' and " with HTML entities.
|
||||
escape(input: string): string;
|
||||
|
||||
// remove characters with a numerical value < 32 and 127
|
||||
stripLow(input: string, keep_new_lines?: boolean): string;
|
||||
|
||||
// remove characters that do not appear in the whitelist.
|
||||
whitelist(input: string, chars: string): string;
|
||||
|
||||
// remove characters that appear in the blacklist.
|
||||
blacklist(input: string, chars: string): string;
|
||||
|
||||
// canonicalize an email address.
|
||||
normalizeEmail(email: string, options?: IEmailoptions): string;
|
||||
}
|
||||
|
||||
declare module "validator" {
|
||||
var validator: IValidatorStatic;
|
||||
export = validator;
|
||||
}
|
||||
Reference in New Issue
Block a user