-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.js
35 lines (26 loc) · 806 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';
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 {
globalThis.ReadableStream = await import('web-streams-polyfill/ponyfill/es2018');
} catch {}
}
const {default: ky, HTTPError, TimeoutError} = await import('ky');
export default ky;
export {HTTPError, TimeoutError};