-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.js
35 lines (27 loc) · 845 Bytes
/
index.js
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
import fetch, {Headers, Request, Response} from 'node-fetch';
import AbortController from 'abort-controller';
import ky from 'ky';
const TEN_MEGABYTES = 1000 * 1000 * 10;
if (!globalThis.fetch) {
globalThis.fetch = (url, options) => fetch(url, {highWaterMark: TEN_MEGABYTES, ...options});
}
if (!globalThis.Headers) {
globalThis.Headers = Headers;
}
if (!globalThis.Request) {
globalThis.Request = Request;
}
if (!globalThis.Response) {
globalThis.Response = Response;
}
if (!globalThis.AbortController) {
globalThis.AbortController = AbortController;
}
if (!globalThis.ReadableStream) {
try {
// eslint-disable-next-line node/file-extension-in-import, node/no-unsupported-features/es-syntax
globalThis.ReadableStream = await import('web-streams-polyfill/ponyfill/es2018');
} catch {}
}
export default ky;
export * from 'ky';