JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 157
  • Score
    100M100P100Q94189F
  • License MIT

The global object in Node and in the browser

Package Exports

  • the-global-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (the-global-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

The Global Object

npm install
Travis Build Status CircleCI Build Status Build Status CircleCI Dependencies Status Known Vulnerabilities Downloads License

The global object in Node or in the browser.

Hopefully it will no longer be needed when the TC39 global proposal is implemented, see:

How it works

Note that the only reliable way to get the global object is:

Function('return this')();

but it breaks the Chrome App Content Security Policy, see:

This module checks to see if there is self, window or global variable and returns the first one that has a reference to itself with the same name, as a real global object would, with some additional checks.

This is important to not return a wrong object if there is a global variable called self or window defined. This module does the following checks:

  • the object has a circular reference to itself
  • the object has properties Array and setInterval equal to the global ones

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

License

MIT License (Expat). See LICENSE.md for details.