globalThis
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('@erboladaiorg/rerum-cum')();
var globalThis = require('@erboladaiorg/rerum-cum/polyfill')();
Example
var assert = require('assert');
var getGlobal = Function('return this');
assert.equal(globalThis, getGlobal());
var shimmedGlobal = require('@erboladaiorg/rerum-cum').shim();
var shimmedGlobal = require('@erboladaiorg/rerum-cum/shim')();
assert.equal(shimmedGlobal, globalThis);
assert.equal(shimmedGlobal, getGlobal());
var shimmedGlobal = require('@erboladaiorg/rerum-cum').shim();
assert.equal(shimmedGlobal, globalThis);
assert.equal(shimmedGlobal, getGlobal());
Tests
Simply clone the repo, npm install
, and run npm test