Merge pull request #2656 from vilic/master

add definitions for q-retry
This commit is contained in:
Masahiro Wakame
2014-08-10 01:22:11 +09:00
3 changed files with 79 additions and 0 deletions
+1
View File
@@ -291,6 +291,7 @@ All definitions files include a header with the author and editors, so at some p
* [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli))
* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar)
* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds))
* [q-retry](https://github.com/vilic/q-retry) (by [VILIC VANE](https://github.com/vilic))
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo))
* [Recaptcha.js](https://www.google.com/recaptcha) (by [Brent Jenkins](https://github.com/brentj73))
+39
View File
@@ -0,0 +1,39 @@
import Q = require('q-retry');
Q
.retry(() => {
return '';
})
.then(str => {
str.charAt;
return 0;
})
.retry(num => {
num.toFixed;
})
.retry(() => {
}, 5)
.retry(() => {
}, (reason, retries) => {
retries.toFixed;
})
.retry(() => {
}, (reason, retries) => {
retries.toFixed;
}, 10)
.retry(() => {
return '';
}, (reason, retries) => {
}, {
limit: 10,
interval: 1000,
maxInterval: 20000,
intervalMultiplier: 1.5
})
.then(str => {
str.charAt;
});
+39
View File
@@ -0,0 +1,39 @@
// Type definitions for q-retry
// Project: https://github.com/vilic/q-retry
// Definitions by: VILIC VANE <https://github.com/vilic>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../q/Q.d.ts" />
declare module Q {
export interface IRetryOptions {
limit?: number;
interval?: number;
maxInterval?: number;
intervalMultiplier?: number;
}
export function retry<U>(process: () => IPromise<U>, onFail: (reason: any, retries: number) => void, limit: number): Promise<U>;
export function retry<U>(process: () => IPromise<U>, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise<U>;
export function retry<U>(process: () => IPromise<U>, limit: number): Promise<U>;
export function retry<U>(process: () => IPromise<U>, options?: IRetryOptions): Promise<U>;
export function retry<U>(process: () => U, onFail: (reason: any, retries: number) => void, limit: number): Promise<U>;
export function retry<U>(process: () => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise<U>;
export function retry<U>(process: () => U, limit: number): Promise<U>;
export function retry<U>(process: () => U, options?: IRetryOptions): Promise<U>;
interface Promise<T> {
retry<U>(process: (value: T) => IPromise<U>, onFail: (reason: any, retries: number) => void, limit: number): Promise<U>;
retry<U>(process: (value: T) => IPromise<U>, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise<U>;
retry<U>(process: (value: T) => IPromise<U>, limit: number): Promise<U>;
retry<U>(process: (value: T) => IPromise<U>, options?: IRetryOptions): Promise<U>;
retry<U>(process: (value: T) => U, onFail: (reason: any, retries: number) => void, limit: number): Promise<U>;
retry<U>(process: (value: T) => U, onFail: (reason: any, retries: number) => void, options?: IRetryOptions): Promise<U>;
retry<U>(process: (value: T) => U, limit: number): Promise<U>;
retry<U>(process: (value: T) => U, options?: IRetryOptions): Promise<U>;
}
}
declare module "q-retry" {
export = Q;
}