-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.ts
41 lines (36 loc) · 1.12 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
fetch as _fetch,
AbortController as _AbortController,
Blob as _Blob,
File as _File,
FormData as _FormData,
Headers as _Headers,
Request as _Request,
Response as _Response,
} from "./node";
export {
AbortError,
FetchError,
blobFrom,
blobFromSync,
fileFrom,
fileFromSync,
isRedirect,
} from "./node";
const _forceNodeFetch = !!globalThis.process?.env?.FORCE_NODE_FETCH;
function _getFetch() {
if (!_forceNodeFetch && globalThis.fetch) {
return globalThis.fetch;
}
return _fetch;
}
export const fetch = _getFetch();
export default fetch;
export const Blob = (!_forceNodeFetch && globalThis.Blob) || _Blob;
export const File = (!_forceNodeFetch && globalThis.File) || _File;
export const FormData = (!_forceNodeFetch && globalThis.FormData) || _FormData;
export const Headers = (!_forceNodeFetch && globalThis.Headers) || _Headers;
export const Request = (!_forceNodeFetch && globalThis.Request) || _Request;
export const Response = (!_forceNodeFetch && globalThis.Response) || _Response;
export const AbortController =
(!_forceNodeFetch && globalThis.AbortController) || _AbortController;