blob: 83c54c584424db362d563217988895aecbc2719c [file] [log] [blame]
Simon Zünd5f6c0652020-11-04 12:51:42 +01001"use strict";
2
3// ref: https://github.com/tc39/proposal-global
4var getGlobal = function () {
5 // the only reliable means to get the global object is
6 // `Function('return this')()`
7 // However, this causes CSP violations in Chrome apps.
8 if (typeof self !== 'undefined') { return self; }
9 if (typeof window !== 'undefined') { return window; }
10 if (typeof global !== 'undefined') { return global; }
11 throw new Error('unable to locate global object');
12}
13
14var global = getGlobal();
15
16module.exports = exports = global.fetch;
17
18// Needed for TypeScript and Webpack.
19if (global.fetch) {
20 exports.default = global.fetch.bind(global);
21}
22
23exports.Headers = global.Headers;
24exports.Request = global.Request;
25exports.Response = global.Response;