Skip to content

Instantly share code, notes, and snippets.

@RubaXa
Last active June 3, 2020 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubaXa/078395065c3aa0ffee557fe072a70c57 to your computer and use it in GitHub Desktop.
Save RubaXa/078395065c3aa0ffee557fe072a70c57 to your computer and use it in GitHub Desktop.
globalThis globalLocation &
export const noop = () => {};
export const nativeGlobalThis = (0
|| typeof globalThis === 'object' && globalThis
|| typeof window === 'object' && window
|| typeof global === 'object' && global
|| {}
) as Window;
export const globalLocation = nativeGlobalThis.location || {
href: '',
hash: '',
host: '',
hostname: '',
search: '',
pathname: '',
protocol: 'https://',
port: '80',
origin: '',
assign: noop,
reload: noop,
replace: noop,
toString() {
return this.href;
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment