retrier.d.ts 1019 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * A class that manages a queue of retry jobs.
  3. */
  4. export class Retrier {
  5. /**
  6. * Creates a new instance.
  7. * @param {Function} check The function to call.
  8. * @param {object} [options] The options for the instance.
  9. * @param {number} [options.timeout] The timeout for the queue.
  10. * @param {number} [options.maxDelay] The maximum delay for the queue.
  11. */
  12. constructor(check: Function, { timeout, maxDelay }?: {
  13. timeout?: number | undefined;
  14. maxDelay?: number | undefined;
  15. } | undefined);
  16. /**
  17. * Adds a new retry job to the queue.
  18. * @param {Function} fn The function to call.
  19. * @param {object} [options] The options for the job.
  20. * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation.
  21. * @returns {Promise<any>} A promise that resolves when the queue is
  22. * processed.
  23. */
  24. retry(fn: Function, { signal }?: {
  25. signal?: AbortSignal | undefined;
  26. } | undefined): Promise<any>;
  27. #private;
  28. }