| 48 | } |
| 49 | |
| 50 | export default function fetch( |
| 51 | input: RequestInfo, |
| 52 | init?: RequestInit |
| 53 | ): Promise<Response> { |
| 54 | const options = { ...init } as RequestInit & { |
| 55 | dispatcher?: FetchDispatcher; |
| 56 | duplex?: 'half'; |
| 57 | }; |
| 58 | |
| 59 | if (fetchDispatcher) { |
| 60 | options.dispatcher = fetchDispatcher; |
| 61 | } |
| 62 | |
| 63 | if (init?.body instanceof Readable) { |
| 64 | options.duplex = 'half'; |
| 65 | } |
| 66 | |
| 67 | return globalThis.fetch( |
| 68 | input, |
| 69 | options as unknown as NativeRequestInit |
| 70 | ) as Promise<Response>; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Like {@link fetch}, but never applies the global proxy-aware dispatcher. |