@fastblob/fast-fetch
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

fast-fetch

fetch fastly in browser.

CI

How It Works

fast-fetch is a drop-in replacement of fetch API, it segments the request into multiple chunks, and fetch them in parallel, then merge them into a single response.

Usage

import fetch from '@fastblob/fast-fetch';
const response = await fetch('https://example.com/test.bin', {
  fastFetch: {
    mirrorURLs: ['https://anotherexample.com/test.bin']
  }
});

Configuration

// src/get/request/types.ts

type FetchInput =  Parameters<typeof fetch>[0]

interface FastFetchGetConfig {
  mirrorURLs?: FetchInput[] // mirror URLs
  maxRetries?: number // max retry for each mirror
  retryDelay?: number // delay between retries
  logger?: Partial<Logger> // logger
  chunkCallback?: (chunk: Blob, range: [number, number], input: FetchInput) => void
}

Note

Only GET and HEAD requests are supported. Other methods will use the original fetch API.

Polyfills?

caniuse polyfill
AbortController mo/abortcontroller-polyfill
Blob API: stream eligrey/Blob.js
Promise.any zloirock/corejs
TransformStream MattiasBuelens/web-streams-polyfill

License

MIT

/@fastblob/fast-fetch/

    Package Sidebar

    Install

    npm i @fastblob/fast-fetch

    Weekly Downloads

    11

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    51.1 kB

    Total Files

    107

    Last publish

    Collaborators

    • seedgou
    • fastblob