Rocky_Mountain_Vending/.pnpm-store/v10/files/4c/51fb6251856836e50ac2eb67e8093da30c972992493e0b91d2d85fc0cd112a192eb2fd39143d9701a7a684ba1e961d2641c521988422de8709064b451acc96
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

29 lines
1.1 KiB
Text

/* IMPORT */
import { RETRY_INTERVAL } from './constants.js';
/* MAIN */
const retryifyAsync = (fn, options) => {
const { isRetriable } = options;
return function retryified(options) {
const { timeout } = options;
const interval = options.interval ?? RETRY_INTERVAL;
const timestamp = Date.now() + timeout;
return function attempt(...args) {
return fn.apply(undefined, args).catch((error) => {
if (!isRetriable(error))
throw error;
if (Date.now() >= timestamp)
throw error;
const delay = Math.round(interval * Math.random());
if (delay > 0) {
const delayPromise = new Promise(resolve => setTimeout(resolve, delay));
return delayPromise.then(() => attempt.apply(undefined, args));
}
else {
return attempt.apply(undefined, args);
}
});
}; //TSC
};
};
/* EXPORT */
export default retryifyAsync;