
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
stubbornizeasync
Advanced tools
Helper for making an async function stubborn (retry the operation on failure)
Create a "stubborn" version of an asynchronous function so that the operation is retried a configurable number of times in case the original function returns an error.
var stubbornizeAsync = require('stubbornizeasync');
// This function will fail ~10% of the time
function myFlakyFunction(cb) {
setTimeout(function () {
if (Math.random() > .9) {
cb(new Error("whoops"));
} else {
cb();
}
}, 10);
}
// This function will fail ~1% of the time:
var stubbornFunction = stubbornizeAsync(myFlakyFunction, {numRetries: 1});
// This function will fail ~0.01% of the time:
var evenMoreStubbornFunction = stubbornizeAsync(myFlakyFunction, {numRetries: 3});
evenMoreStubbornFunction(function (err) {
if (err) {
throw err;
} else {
// Yay!
}
});
By default the stubbornized function retries the original function 3
times (so it's run a maximum of 4 times), and it waits 250
milliseconds between the attempts. These parameters can be adjusted by
providing an options object as the second parameter to
stubbornizeAsync:
var veryStubbornAndVeryPatientFunction = stubbornizeAsync(myFlakyFunction, {numRetries: 10, delayMsec: 10000});
Make sure you have node.js and npm installed, then run:
npm install stubbornizeasync
3-clause BSD license -- see the LICENSE file for details.
FAQs
Helper for making an async function stubborn (retry the operation on failure)
The npm package stubbornizeasync receives a total of 772 weekly downloads. As such, stubbornizeasync popularity was classified as not popular.
We found that stubbornizeasync 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.