diff --git a/bluebird-retry/bluebird-retry-tests.ts b/bluebird-retry/bluebird-retry-tests.ts new file mode 100644 index 000000000..5d8c32dfc --- /dev/null +++ b/bluebird-retry/bluebird-retry-tests.ts @@ -0,0 +1,35 @@ +/// +/// +import Promise = require('bluebird'); +import retry = require('bluebird-retry'); + +function promiseSuccess(text:string) { + return Promise.resolve(text); +}; + +var count = 0; +function myfunc() { + console.log('myfunc called ' + (++count) + ' times'); + if (count < 3) { + throw new Error('i fail the first two times'); + } else { + return promiseSuccess('i succeed the third time'); + } +} + +retry(myfunc) + .done(function(result) { console.log(result); } ); + + +//Options example +function logFail() { + console.log(new Date().toISOString()); + throw new Error('bail'); +} + +var options:retry.Options = { + max_tries: 4, + interval: 500 +}; + +retry(logFail, options); \ No newline at end of file diff --git a/bluebird-retry/bluebird-retry.d.ts b/bluebird-retry/bluebird-retry.d.ts new file mode 100644 index 000000000..3719e5e3a --- /dev/null +++ b/bluebird-retry/bluebird-retry.d.ts @@ -0,0 +1,24 @@ +// Type definitions for bluebird-retry +// Project: https://github.com/jut-io/bluebird-retry +// Definitions by: Pascal Vomhoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module "bluebird-retry" { + import Promise = require('bluebird'); + + function retry(func:(param:T)=>void, options?:retry.Options):Promise; + + module retry { + export interface Options { + interval?:number; + backoff?:number; + max_interval?:number; + timeout?:number; + max_tries?:number; + } + + } + + export = retry; +} \ No newline at end of file