fetchWorker: support RequestInit

This commit is contained in:
Alex Gleason
2023-11-28 20:55:43 -06:00
parent 5a954a304d
commit da3efaa5bc
5 changed files with 79 additions and 8 deletions

View File

@@ -1,8 +1,14 @@
import { Comlink } from '@/deps.ts';
import './handlers/abortsignal.ts';
export const FetchWorker = {
async fetch(url: string): Promise<[BodyInit, ResponseInit]> {
const response = await fetch(url);
async fetch(
url: string,
init: Omit<RequestInit, 'signal'>,
signal: AbortSignal | null | undefined,
): Promise<[BodyInit, ResponseInit]> {
const response = await fetch(url, { ...init, signal });
return [
await response.text(),
{