Options
All
  • Public
  • Public/Protected
  • All
Menu

TransferManager for downloading URLs.

Features:

  • Merges JSON downloads, for example, the same URL if requested as JSON will only be downloaded once.
  • Limits the amount of parallel downloads, useful when requesting a large amount of URLs that would otherwise stall the browser.
  • Retries the downloads with an increasing timeout on HTTP 503 replies.

The static method instance can be used to get a default constructed instance.

Hierarchy

  • TransferManager

Implements

Index

Constructors

constructor

  • new TransferManager(fetchFunction?: fetch, maxRetries?: number): TransferManager

Properties

Readonly fetchFunction

fetchFunction: fetch

The default fetch function to use.

Readonly maxRetries

maxRetries: number

The maximum amount to try to re-fetch a resource.

Static Readonly maxParallelDownloads

maxParallelDownloads: 16 = 16

The amount of maximum parallel downloads to allow.

Static Readonly retryTimeout

retryTimeout: 500 = 500

The timeout in milliseconds to wait between retries. This timeout is multiplied with the number of retries. First retry waits for 0 ms, second retry for 500 ms, third for 1000 ms and so on.

Methods

download

  • download(url: RequestInfo, init?: RequestInit): Promise<Response>

downloadArrayBuffer

  • downloadArrayBuffer(url: RequestInfo, init?: RequestInit): Promise<ArrayBuffer>
  • Downloads a binary object. Merges downloads of string URLS if requested multiple times.

    Note: This method merges multiple downloads of the same string URL to only one request. The init parameter is ignored if the download is merged. Call download instead to download the resource without merging.

    Parameters

    • url: RequestInfo

      The URL or RequestInfo to download

    • Optional init: RequestInit

      Optional extra parameters for the download

    Returns Promise<ArrayBuffer>

downloadJson

  • downloadJson<T>(url: RequestInfo, init?: RequestInit): Promise<T>
  • Downloads a JSON object. Merges downloads of string URLs if requested multiple times.

    Note: This method merges multiple downloads of the same string URL to only one request. The init parameter is ignored if the download is merged. Call download instead to download the resource without merging.

    Type parameters

    • T

    Parameters

    • url: RequestInfo

      The URL or RequestInfo to download

    • Optional init: RequestInit

      Optional extra parameters for the download.

    Returns Promise<T>

Static instance

Generated using TypeDoc