Socket
Book a DemoInstallSign in
Socket

retry-until

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retry-until

Just a way to keep calling a function as long as it's throwing, for some period of time.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

retry-until

Just a way to keep calling a function as long as it's throwing, for some period of time.

If the function returns a promise, it'll keep retrying the promise as long as it keeps throwing, for the time specified.

USAGE

const retryUntil = require('retry-until')
const retryFor1Second = retryUntil(1000) // retry for 1 second
const retryFor10Seconds = retryUntil(10000) // retry for 10 seconds

// this will busy-loop calling the function as fast as it can for
// up to 1s, or until it returns without throwing, whichever comes first
retryFor1Second(syncFunctionThatSometimesThrowsForAWhile, 'some', 'args')

// this will keep re-calling the Promise-returning function as long as it
// keeps rejecting, or for 10s, whichever comes first
const result = await retryFor10Seconds(asyncFunctionThatSometimesRejects, 'some', 'other', 'args')

API

  • retryUntil(duration) -> Function

Returns a function that will take a function and some arguments, and then run the function repeatedly for up to duration milliseconds.

FAQs

Package last updated on 05 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts