globalthis
Advanced tools
Weekly downloads
Changelog
v1.0.3 - 2022-05-07
65891e4
node/install
instead of node/run
; use codecov
action 82f8481
npmignore
to autogenerate an npmignore file 53afc39
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, tape
03169d4
eslint
, @ljharb/eslint-config
, safe-publish-latest
, tape
4986e3e
15c4b06
eslint
, @ljharb/eslint-config
, auto-changelog
, tape
8b04a74
globalThis
should be writable 8759985
0263f0d
aud
, eslint
, tape
e88d296
prepublishOnly
script for npm 7+ c81fde6
dist
bde0c0d
79f73f8
Readme
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
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());
Simply clone the repo, npm install
, and run npm test
ECMAScript spec-compliant polyfill/shim for `globalThis`
The npm package globalthis receives a total of 12,046,112 weekly downloads. As such, globalthis popularity was classified as popular.
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.
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.