/trymore

This function helps you handle errors in a flexible and customizable way, allowing you to retry operations by passing a new callback to the trymore method.

Primary LanguageTypeScript

Trymore

Trymore is a flexible and customizable function for handling errors It allows you to retry operations by passing a new callback to the trymore() method. The function is simple yet powerful, and can be easily integrated into your projects.

NPM version NPM downloads github

Table of Contents

Type

  • ECMAScript Modules (ESM)
  • CommonJS (CJS)

Installation

npm install trymore
yarn add trymore

Example

CommonJS

const trymore = require("trymore").default;
trymore(() => {
  //just to throw an error
  console.log(focus());
  [].toErrorTestTest();
  throw new Error("Test");
})
  .trymore(() => {
    console.log("success"); //stop here because no error, game over
  })
  .trymore(() => {
    throw new Error("Any Error"); //disregard this because the second trymore is already success
  });

ES6

import trymore from "trymore";
trymore(() => {
  //just to throw an error
  console.log(focus());
  [].toErrorTestTest();
  throw new Error("Test");
})
  .trymore(() => {
    console.log("success"); //stop here because no error, game over
  })
  .trymore(() => {
    throw new Error("Any Error"); //disregard this because the second trymore is already success
  });

License

trymore is licensed under the Apache-2.0