Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

globalthis

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Issues
File Explorer

Advanced tools

globalthis

ECMAScript spec-compliant polyfill/shim for `globalThis`

    1.0.3latest
    Github

Version published
Maintainers
1
Weekly downloads
12,673,118
increased by11.84%

Weekly downloads

Changelog

Source

v1.0.3 - 2022-05-07

Commits

Readme

Source

globalThis Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ECMAScript spec-compliant polyfill/shim for globalThis. Invoke its "shim" method to shim globalThis if it is unavailable.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec proposal.

Most common usage:

var globalThis = require('globalthis')(); // returns native globalThis if compliant /* or */ var globalThis = require('globalthis/polyfill')(); // returns native globalThis if compliant

Example

var assert = require('assert'); // the below function is not CSP-compliant, but reliably gets the // global object in sloppy mode in every engine. var getGlobal = Function('return this'); assert.equal(globalThis, getGlobal()); /* when `globalThis` is not present */ var shimmedGlobal = require('globalthis').shim(); /* or */ var shimmedGlobal = require('globalthis/shim')(); assert.equal(shimmedGlobal, globalThis); assert.equal(shimmedGlobal, getGlobal()); /* when `globalThis` is present */ var shimmedGlobal = require('globalthis').shim(); assert.equal(shimmedGlobal, globalThis); assert.equal(shimmedGlobal, getGlobal());

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

What is globalthis?

ECMAScript spec-compliant polyfill/shim for `globalThis`

Is globalthis popular?

The npm package globalthis receives a total of 12,046,112 weekly downloads. As such, globalthis popularity was classified as popular.

Is globalthis well maintained?

We found that globalthis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 07 May 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc