rrudol / never-give-up

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

Home Page:https://www.npmjs.com/package/never-give-up

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

https://www.npmjs.com/package/never-give-up

License:MIT License


Languages

Language:TypeScript 63.1%Language:JavaScript 36.9%