1.0.3 • Published 2 years ago

globalthis v1.0.3

Weekly downloads
2,798,248
License
MIT
Repository
github
Last release
2 years ago

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

es-abstractairbnb-js-shimsreflect.ownkeysarchetype-library@axa-ch/pod-kmu-20easy-select-rnnext-universal-storage@sophia-iot/library-componentsdependencies-install-testquoc-testone-index@saaspe/componentsexpand-react-bridgeopea-bootstraapluminos-ui-coresklif-ui-kitsklif-api@everything-registry/sub-chunk-1771jawwy-sdkjawwy_gamification_release@deepakorg/test@deepak757/testreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-tablesklif-uimachinebeemrcapsreact-native-jawwy_samplekrondoleletherego932letsgoobraderkarvickytea93klosokintilidin15lapture-ui-complaptureuilembah1leonardsinggihtea46leadengageminatonamikaze63node-domexception-polyfillmxmilsmyzallmtva-teleport-toolmggauharmostjulien-easy-modaljusmelon204my-rizki-appnative-modal-damage-vehiclemy-library-buttonnew-awesome-4321menyalatea021nodered-contrib-sms77novacap-components@valifysolutions/react-native-vidvliveness@vasosolo/multiselectcombobox@traitsniper/web3-react-connector@traitsniper/web3-react-v6-connector@ucd-lib/cork-app-build@thewtex/vtk.js-esm@thuromun/thurotea@titani0us/airbrake@umn-latis/simple-smoothing-spline@thinxviewx/core-rn@vitali_shcherbina/styled-lib@tuannm301198/changeset-test@skedulr/nebula-ui-library@startbahn/startrail-sdk-js@status-im/react-native-transparent-video@stasa87/react-insta-stories@sudophunk/fulido@sudophunk/v4-client@stunned/svelte-previous@swishjam/clientjs@teapucuk46/azumietea66@techdacxi/capacitor-persona-plugin@tusken-s/facebook-tools@taingo97/react-native-awesome-module@taingo97/react-native-bluetooth-xprinter@taingo97/react-native-expo-key-rsa-kt@taingo97/react-native-expo-rsa@taingo97/react-native-generate-key-rsa@taingo97/react-native-key-rsa@taingo97/react-native-print-xprinter@taingo97/react-native-rsa@taingo97/react-native-rsa-expo@taingo97/react-native-sunmi-printer@taingo97/react-native-telpo-printer@taskless/devakatsukitearxx@w3bstream/geolocation@worl2slim/gentcomos@zoldixs/zoldixs-tea@tukijo/klosoagent-get-agentadarshsinghal-editor-preview
1.0.3

2 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

6 years ago