1 | import AbortController, { AbortSignal } from './abortcontroller';
|
2 | import abortableFetch from './abortableFetch';
|
3 | import { polyfillNeeded } from './utils';
|
4 |
|
5 | (function (self) {
|
6 | 'use strict';
|
7 |
|
8 | if (!polyfillNeeded(self)) {
|
9 | return;
|
10 | }
|
11 |
|
12 | if (!self.fetch) {
|
13 | console.warn('fetch() is not available, cannot install abortcontroller-polyfill');
|
14 | return;
|
15 | }
|
16 |
|
17 | const { fetch, Request } = abortableFetch(self);
|
18 | self.fetch = fetch;
|
19 | self.Request = Request;
|
20 |
|
21 | Object.defineProperty(self, 'AbortController', {
|
22 | writable: true,
|
23 | enumerable: false,
|
24 | configurable: true,
|
25 | value: AbortController,
|
26 | });
|
27 |
|
28 | Object.defineProperty(self, 'AbortSignal', {
|
29 | writable: true,
|
30 | enumerable: false,
|
31 | configurable: true,
|
32 | value: AbortSignal,
|
33 | });
|
34 | })(typeof self !== 'undefined' ? self : global);
|