https://github.com/wwwflorencio/await-retry
https://github.com/wwwflorencio/await-retry
async await brazil javascript new-feature nodejs promise retry-library retry-strategies
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/wwwflorencio/await-retry
- Owner: wwwflorencio
- License: mit
- Created: 2018-08-21T03:44:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T22:43:24.000Z (about 7 years ago)
- Last Synced: 2025-06-12T07:53:46.492Z (4 months ago)
- Topics: async, await, brazil, javascript, new-feature, nodejs, promise, retry-library, retry-strategies
- Language: JavaScript
- Size: 10.7 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# await-retry
# install
`npm i await-retry --save`# usage example
```js
const { retry } = require('await-retry')function getUser () {
return {
message: 'wow, amazing',
user: {
name: 'enzo'
}
}
}function getUserWithError () {
throw new Error('oh no')
}async function start () {
console.log(await retry(getUser, { tries: 2 }))
/**
{
tries: 1,
success: true,
result: { message: 'wow, amazing', user: { name: 'enzo' } },
}
*/console.log(await retry(getUserWithError, { tries: 2 }))
/**
* {
tries: 2,
success: false,
errors: [Error: oh no..., Error: oh no]
}
*/
}start()
```