/** * Helpers for dealing with fetch requests */ import { TaskEither } from "fp-ts/lib/TaskEither"; import { MaxRetries, RetriableTask, RetryAborted } from "./tasks"; import { ITuple2 } from "./tuples"; import { Millisecond } from "./units"; import "abort-controller/polyfill"; /** * An instance of fetch, along its associated AbortController */ export type AbortableFetch = (input: RequestInfo | URL, init?: RequestInit) => ITuple2, AbortController>; /** * Makes fetch abortable and returns an AbortableFetch. * * The fetch request can be aborted by calling `AbortController`'s `abort()`. * * See https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort */ export declare function AbortableFetch(origFetch?: typeof fetch): AbortableFetch; /** * Converts an AbortableFetch back to a simple fetch */ export declare const toFetch: (f: AbortableFetch) => (input: RequestInfo | URL, init?: RequestInit) => Promise; /** * Sets a timeout on an AbortableFetch. * * When the timeout expires, the controller's `abort()` method gets called. */ export declare function setFetchTimeout(timeout: Millisecond, abortableFetch: AbortableFetch): AbortableFetch; /** * Given a function that wraps a RetriableTask with retries, it returns an * fetch that wraps the original fetch with retries on transient errors such * as network errors and timeouts. */ export declare const retriableFetch: (retryWrapper: (_: RetriableTask, shouldAbort?: Promise) => TaskEither, shouldAbort?: Promise) => (f: typeof fetch) => typeof fetch;