mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 23:20:02 +00:00
29 lines
640 B
TypeScript
29 lines
640 B
TypeScript
import {
|
|
supportsNativeFetch,
|
|
supportsSendBeacon,
|
|
supportsXMLHttpRequest
|
|
} from "./featureDetection";
|
|
import type { RequestFnType } from "./request";
|
|
import {
|
|
requestWithNativeFetch,
|
|
requestWithSendBeacon,
|
|
requestWithXMLHttpRequest
|
|
} from "./request";
|
|
|
|
export function getRequesterForBrowser(): RequestFnType {
|
|
if (supportsSendBeacon()) {
|
|
return requestWithSendBeacon;
|
|
}
|
|
|
|
if (supportsXMLHttpRequest()) {
|
|
return requestWithXMLHttpRequest;
|
|
}
|
|
|
|
if (supportsNativeFetch()) {
|
|
return requestWithNativeFetch;
|
|
}
|
|
|
|
throw new Error(
|
|
"Could not find a supported HTTP request client in this environment."
|
|
);
|
|
}
|