source: imaps-frontend/node_modules/globalthis/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.7 KB
Line 
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```js
18var globalThis = require('globalthis')(); // returns native globalThis if compliant
19 /* or */
20var globalThis = require('globalthis/polyfill')(); // returns native globalThis if compliant
21```
22
23## Example
24
25```js
26var assert = require('assert');
27
28// the below function is not CSP-compliant, but reliably gets the
29// global object in sloppy mode in every engine.
30var getGlobal = Function('return this');
31
32assert.equal(globalThis, getGlobal());
33```
34
35```js
36/* 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```js
46/* when `globalThis` is present */
47var shimmedGlobal = require('globalthis').shim();
48
49assert.equal(shimmedGlobal, globalThis);
50assert.equal(shimmedGlobal, getGlobal());
51```
52
53## Tests
54Simply clone the repo, `npm install`, and run `npm test`
55
56[npm-url]: https://npmjs.org/package/globalthis
57[npm-version-svg]: https://versionbadg.es/ljharb/globalThis.svg
58[deps-svg]: https://david-dm.org/ljharb/globalThis.svg?theme=shields.io
59[deps-url]: https://david-dm.org/ljharb/globalThis
60[dev-deps-svg]: https://david-dm.org/ljharb/globalThis/dev-status.svg?theme=shields.io
61[dev-deps-url]: https://david-dm.org/ljharb/globalThis#info=devDependencies
62[npm-badge-png]: https://nodei.co/npm/globalthis.png?downloads=true&stars=true
63[license-image]: https://img.shields.io/npm/l/globalthis.svg
64[license-url]: LICENSE
65[downloads-image]: https://img.shields.io/npm/dm/globalthis.svg
66[downloads-url]: https://npm-stat.com/charts.html?package=globalthis
67[codecov-image]: https://codecov.io/gh/es-shims/globalThis/branch/main/graphs/badge.svg
68[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/globalThis
70[actions-url]: https://github.com/es-shims/globalThis/actions
Note: See TracBrowser for help on using the repository browser.