@exodus/simple-retry
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"private": false, | ||
"name": "@exodus/simple-retry", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Simple Retry", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -1,8 +0,3 @@ | ||
# Simple Retry | ||
# Simple Retry [![Build Status](https://travis-ci.com/ExodusMovement/simple-retry.svg?token=4LdsYhfLJBfrCJSUBSTg&branch=master)](https://travis-ci.com/ExodusMovement/simple-retry) | ||
## Setup CI | ||
1. To install Travis CI into the repository: [link](https://github.com/apps/travis-ci/installations/new/permissions?suggested_target_id=16415174) | ||
2. Choose: Only Select Repositories | ||
## Getting Started | ||
@@ -14,2 +9,27 @@ | ||
## Usage | ||
```js | ||
import { retry } from '@exodus/simple-retry' | ||
const broadcastTxWithRetry = retry(broadcastFunction, { delayTimesMs: ['10s'] }) | ||
const result = await broadcastTxWithRetry(plainTx) | ||
``` | ||
It is possible to trap specific errors and mark them as final when retrying is not needed, like: | ||
```js | ||
const broadcastTxWithRetry = retry( | ||
async (plainTx) => { | ||
try { | ||
return await broadcastFunction(plainTx) | ||
} catch (e) { | ||
if (/specific-final-error/i.test(e.message)) e.finalError = true | ||
throw e | ||
} | ||
}, | ||
{ delayTimesMs: ['10s'] } | ||
) | ||
``` | ||
## Tests | ||
@@ -16,0 +36,0 @@ |
5695
53