UNPKG

@reservoir0x/relay-sdk

Version:

Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.

19 lines 726 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.repeatUntilOk = void 0; async function repeatUntilOk(callback, maximumAttempts = 15, attemptCount = 0, pollingInterval = 5000) { if (attemptCount >= maximumAttempts) { throw `Failed to get an ok response after ${attemptCount} attempt(s), aborting`; } const response = await callback(); if (response) { return true; } else { await new Promise((resolve) => setTimeout(resolve, pollingInterval)); attemptCount++; await repeatUntilOk(callback, maximumAttempts, attemptCount, pollingInterval); } } exports.repeatUntilOk = repeatUntilOk; //# sourceMappingURL=repeatUntilOk.js.map