Skip to content

rrudol/never-give-up

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

never-give-up npm version Dependency Status devDependency Status Build Status

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.

Instalation

npm install never-give-up --save

Usage

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?
  }
}

License

MIT

About

A module which force async functions to return value, by repeating them infinite number of times, ignoring undefined values and exceptions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published