CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md71 linesDownload Raw Back to globalthis
1# globalThis <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>2 3[![github actions][actions-image]][actions-url]4[![coverage][codecov-image]][codecov-url]5[![dependency status][deps-svg]][deps-url]6[![dev dependency status][dev-deps-svg]][dev-deps-url]7[![License][license-image]][license-url]8[![Downloads][downloads-image]][downloads-url]9 10[![npm badge][npm-badge-png]][npm-url]11 12An ECMAScript spec-compliant polyfill/shim for `globalThis`. Invoke its "shim" method to shim `globalThis` if it is unavailable.13 14This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec proposal](https://github.com/tc39/proposal-global).15 16Most common usage:17```js18var globalThis = require('globalthis')(); // returns native globalThis if compliant19	/* or */20var globalThis = require('globalthis/polyfill')(); // returns native globalThis if compliant21```22 23## Example24 25```js26var assert = require('assert');27 28// the below function is not CSP-compliant, but reliably gets the29// global object in sloppy mode in every engine.30var getGlobal = Function('return this');31 32assert.equal(globalThis, getGlobal());33```34 35```js36/* when `globalThis` is not present */37var shimmedGlobal = require('globalthis').shim();38	/* or */39var shimmedGlobal = require('globalthis/shim')();40 41assert.equal(shimmedGlobal, globalThis);42assert.equal(shimmedGlobal, getGlobal());43```44 45```js46/* when `globalThis` is present */47var shimmedGlobal = require('globalthis').shim();48 49assert.equal(shimmedGlobal, globalThis);50assert.equal(shimmedGlobal, getGlobal());51```52 53## Tests54Simply clone the repo, `npm install`, and run `npm test`55 56[npm-url]: https://npmjs.org/package/globalthis57[npm-version-svg]: https://versionbadg.es/ljharb/globalThis.svg58[deps-svg]: https://david-dm.org/ljharb/globalThis.svg?theme=shields.io59[deps-url]: https://david-dm.org/ljharb/globalThis60[dev-deps-svg]: https://david-dm.org/ljharb/globalThis/dev-status.svg?theme=shields.io61[dev-deps-url]: https://david-dm.org/ljharb/globalThis#info=devDependencies62[npm-badge-png]: https://nodei.co/npm/globalthis.png?downloads=true&stars=true63[license-image]: https://img.shields.io/npm/l/globalthis.svg64[license-url]: LICENSE65[downloads-image]: https://img.shields.io/npm/dm/globalthis.svg66[downloads-url]: https://npm-stat.com/charts.html?package=globalthis67[codecov-image]: https://codecov.io/gh/es-shims/globalThis/branch/main/graphs/badge.svg68[codecov-url]: https://app.codecov.io/gh/es-shims/globalThis/69[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/globalThis70[actions-url]: https://github.com/es-shims/globalThis/actions71 
basant307/AI_Governance_Project · CoolFace