Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
async-await-retry
Advanced tools
Minimalist, efficient and performance focused retry system. Basically it helps developer to retry a function with a specific interval, exponential factor etc.
No dependency.
/!\ This module use async/await syntax, this is why you must have node 7.6+.
Supported and tested : >= 7.6
Version | Supported | Tested |
---|---|---|
10.x | yes | yes |
9.x | yes | yes |
8.x | yes | yes |
>= 7.6 | yes | yes |
$ npm install async-await-retry --save
const retry = require('async-await-retry');
const func = async () => {return new Promise((resolve) => resolve('OK'))};
try {
const res = await retry(func)
} catch (err) {
console.log('The function execution failed !')
}
const retry = require('async-await-retry');
const func = () => {...};
try {
const res = await retry(func)
console.log(res) // output : OK
} catch (err) {
console.log('The function execution failed !')
}
const retry = require('async-await-retry');
try {
const res = await retry(async () => {
return new Promise((resolve) => resolve('OK'))
})
console.log(res) // output : OK
} catch (err) {
console.log('The function execution failed !')
}
const retry = require('async-await-retry');
try {
const res = await retry((arg1, cb) => {
....
cb(err, data); // send err as first argument
}, ["arg1"], {isCb: true});
} catch (err) {
console.log('The function execution failed !')
}
## retry(function, [args], [config])
function
: function to retry in case of errorargs
: your function's parameters in case you don't use callback styleconfig
: an object containing all retry process optionsOption | description | Default value |
---|---|---|
retriesMax | Maximum number of retries | 3 |
interval | Delay in ms between two tentatives | 0 |
exponential | Will the interval increase exponentially ? | true |
factor | The exponential factor to use | 2 |
isCb | Old callback function style ? | false |
An example of custom options :
const retry = require('async-await-retry');
try {
const res = await retry(async () => {
return new Promise((resolve) => resolve('OK'))
}, null, {retriesMax: 4, interval: 100, exponential: true, factor: 3})
console.log(res) // output : OK
} catch (err) {
console.log('The function execution failed !')
}
$ npm test
Coverage report can be found in coverage/.
FAQs
Simple module to retry a function with async/await syntax !
We found that async-await-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.