browser.js 732 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. // ref: https://github.com/tc39/proposal-global
  3. var getGlobal = function () {
  4. // the only reliable means to get the global object is
  5. // `Function('return this')()`
  6. // However, this causes CSP violations in Chrome apps.
  7. if (typeof self !== 'undefined') { return self; }
  8. if (typeof window !== 'undefined') { return window; }
  9. if (typeof global !== 'undefined') { return global; }
  10. throw new Error('unable to locate global object');
  11. }
  12. var global = getGlobal();
  13. module.exports = exports = global.fetch;
  14. // Needed for TypeScript and Webpack.
  15. if (global.fetch) {
  16. exports.default = global.fetch.bind(global);
  17. }
  18. exports.Headers = global.Headers;
  19. exports.Request = global.Request;
  20. exports.Response = global.Response;