0.1.0 • Published 5 years ago

never-give-up v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

never-give-up

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