0.5.0 • Published 7 years ago
@promises/retry v0.5.0
@promises/retry
Retry is package from Promises library
Use
Module
$ npm install --save @promises/retryimport {
default as retry
} from '@promises/retry';Browser
<script src="https://unpkg.com/@promises/retry/bundle.umd.min.js"></script>let {
retry
} = P;Examples
let count: number = 0;
let promise: Promise<string> = retry<string>(()=>{
if(count++ < 2) throw 'error';
return 'foo';
}, {times: 3});
promises.then((result: string) => {
console.log(result); // => 'foo'
});Wrapper
Module
$ npm install --save @promises/retryimport Promises from '@promises/core';
import '@promises/retry/add';Or
import Promises from '@promises/retry/add';Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/retry/add/bundle.umd.min.js"></script>let {
Promises
} = P;Examples
let count: number = 0;
let promises: Promises<string> = Promises.retry(()=>{
if(count++ < 2) throw 'error';
return 'foo';
}, {times: 3});
promises.then((result: string) => {
console.log(result); // => 'foo'
});Compatibility
These modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global Promise (native or polyfill).
License
Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.