Skip to content

The open alternative to Salesforce, designed for AI.

504 B
Raw Blame
import {
  FATHOM_MEDIA_DOWNLOAD_INITIAL_POLL_DELAY_MILLISECONDS,
  FATHOM_MEDIA_DOWNLOAD_MAX_POLL_DELAY_MILLISECONDS,
  FATHOM_MEDIA_DOWNLOAD_POLL_BACKOFF_EXPONENT,
} from 'src/constants/fathom.constant';

export const getFathomMediaDownloadPollDelay = (attempt: number): number =>
  Math.min(
    Math.round(
      FATHOM_MEDIA_DOWNLOAD_INITIAL_POLL_DELAY_MILLISECONDS *
        FATHOM_MEDIA_DOWNLOAD_POLL_BACKOFF_EXPONENT ** attempt,
    ),
    FATHOM_MEDIA_DOWNLOAD_MAX_POLL_DELAY_MILLISECONDS,
  );