Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for globalThis before fallback to shims #20

Merged
merged 5 commits into from
Oct 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { createFetch } from './base'

export * from './base'

// ref: https://github.com/tc39/proposal-global
ms-fadaei marked this conversation as resolved.
Show resolved Hide resolved
const getGlobal = function () {
if (typeof globalThis !== 'undefined') { return globalThis }
if (typeof self !== 'undefined') { return self }
if (typeof window !== 'undefined') { return window }
if (typeof global !== 'undefined') { return global }
throw new Error('unable to locate global object')
return (function() { return this })();
ms-fadaei marked this conversation as resolved.
Show resolved Hide resolved
}

export const fetch = getGlobal().fetch || (() => {
Expand Down