Skip to content

WebForgeOSS/inshallah

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inchallah

A function that wraps the provided function with retry logic.

Tested with Jest Code Style: Prettier

Installation

$ npm install inchallah

Usage

const inshallah = require("inchallah");

const fn = () => {
  // Function to be retried
};

const options = {
  retries: 5, // Number of retries (default: 10)
};

inshallah(deps, fn, options)
  .then((result) => {
    // Handle the result on success
  })
  .catch((error) => {
    // Handle the error on failure or exceeding the maximum number of retries
  });

API

inshallah(deps, fn, options) ⇒ Promise

Wraps the provided function with retry logic.

Returns: Promise - A promise that resolves with the result of the function or rejects with an error.

Parameter Type Description
deps Object Object containing dependencies (e.g., logger)
fn Function The function to be retried
options Object Retry options
options.retries number Number of retries (default: 10)

Example

const inshallah = require("inchallah");

const fn = () => {
  // Function to be retried
};

const options = {
  retries: 5, // Number of retries (default: 10)
};

inshallah(deps, fn, options)
  .then((result) => {
    // Handle the result on success
  })
  .catch((error) => {
    // Handle the error on failure or exceeding the maximum number of retries
  });

License

MIT © muceres

About

Wraps the provided function with retry logic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published