Created
August 10, 2021 10:21
-
-
Save dcorking/fbd203c6696f9b2502af6bfc0b119116 to your computer and use it in GitHub Desktop.
detect global JS feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from https://github.com/github/fetch/blob/master/fetch.js | |
// detecting the existince of fetch() and only patching if it is absent | |
var global = | |
(typeof globalThis !== 'undefined' && globalThis) || | |
(typeof self !== 'undefined' && self) || | |
(typeof global !== 'undefined' && global) || | |
{} | |
export function fetch(input, init) { | |
return new Promise(function(resolve, reject) { | |
// ... | |
} | |
} | |
fetch.polyfill = true | |
if (!global.fetch) { | |
global.fetch = fetch | |
global.Headers = Headers | |
global.Request = Request | |
global.Response = Response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment