devstar插件
This commit is contained in:
29
node_modules/search-insights/lib/utils/getRequesterForBrowser.ts
generated
vendored
Normal file
29
node_modules/search-insights/lib/utils/getRequesterForBrowser.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
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."
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user