A module which force async functions to return value, by repeating them infinite number of times, ignoring undefined values and exceptions.
Could be useful while using crappy systems, but in fact you shouldn't use this package.
npm install never-give-up --save
const { neverGiveUp } = require("never-give-up");
async function russianRoulette() {
if (Math.floor(Math.random() * 100) === 5) {
return true;
}
}
function veryImportantCalculations() {
// const value = await russianRoulette(); <- but why to take such risk?
const value = await neverGiveUp(russianRoulette);
if (value === 5) {
console.log('You\'re lucky!');
} else {
console.log('You fired!'); // It will never run, how cool is that?
}
}