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