import { Runtime } from "#Source/environment/base.index.ts"
import type { BaseFetch, FetchInput, FetchOutput, BaseFetchOptions } from "./base.ts"
import { browserFetch } from "./browser.ts"
import { nodejsFetch } from "./nodejs.ts"
/**
* @description 根据当前运行时选择浏览器或 Node.js 的 fetch 执行器。
*/
export const generalFetch = (
options: BaseFetchOptions,
): BaseFetch => {
const runtimeFetch = Runtime.useRuntimes>({
browser: () => browserFetch(options),
nodejs: () => nodejsFetch(options),
})
return runtimeFetch
}