-
Notifications
You must be signed in to change notification settings - Fork 37
/
fetch-browser.js
37 lines (32 loc) · 1.01 KB
/
fetch-browser.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
36
37
(function (global) {
'use strict';
function fetchPonyfill(options) {
var Promise = options && options.Promise || global.Promise;
var XMLHttpRequest = options && options.XMLHttpRequest || global.XMLHttpRequest;
return (function () {
var globalThis = Object.create(global, {
fetch: {
value: undefined,
writable: true
}
});
// {{whatwgFetch}}
return {
fetch: globalThis.fetch,
Headers: globalThis.Headers,
Request: globalThis.Request,
Response: globalThis.Response,
DOMException: globalThis.DOMException
};
}());
}
if (typeof define === 'function' && define.amd) {
define(function () {
return fetchPonyfill;
});
} else if (typeof exports === 'object') {
module.exports = fetchPonyfill;
} else {
global.fetchPonyfill = fetchPonyfill;
}
}(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof global !== 'undefined' ? global : this));