JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 492
  • Score
    100M100P100Q103235F
  • License MPL-2.0

Provides access to `globalThis`, ensuring cross-platform compatibility, including browsers (`window`), Node.js (`global`), and Web Workers (`self`).

Package Exports

  • @alwatr/global-this

Readme

globalThis

Provides access to globalThis, ensuring cross-platform compatibility, including browsers (window), Node.js (global), and Web Workers (self).

Installation

yarn add @alwatr/global-this

Usage

import {getGlobalThis} from '@alwatr/global-this';

getGlobalThis<{alwatr: {foo: string}}>().alwatr = {
  foo: 'bar',
};
import {getGlobalThis} from '@alwatr/global-this';

getGlobalThis().setTimeout(() => {
  console.log(getGlobalThis<{alwatr: {foo: string}}>().alwatr.foo); // 'bar'
}, 1_000);

Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.