1.0.5 • Published 2 years ago
@fastblob/fast-fetch v1.0.5
fast-fetch
fetch fastly in browser.
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