{"id":13451937,"url":"https://github.com/es-shims/globalThis","last_synced_at":"2025-03-23T19:33:14.972Z","repository":{"id":6220035,"uuid":"55033953","full_name":"es-shims/globalThis","owner":"es-shims","description":"ECMAScript spec-compliant polyfill/shim for `globalThis`.","archived":false,"fork":false,"pushed_at":"2024-04-30T02:35:55.000Z","size":104,"stargazers_count":155,"open_issues_count":2,"forks_count":13,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-20T18:41:13.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/tc39/proposal-global","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/es-shims.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":"npm/es5-shim","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-03-30T05:02:19.000Z","updated_at":"2024-09-27T06:35:44.000Z","dependencies_parsed_at":"2024-06-18T12:32:49.877Z","dependency_job_id":"be37183e-26f3-4000-b2a2-078548cd5394","html_url":"https://github.com/es-shims/globalThis","commit_stats":{"total_commits":82,"total_committers":4,"mean_commits":20.5,"dds":0.03658536585365857,"last_synced_commit":"ac7b854ca44994583a71a5de17dd73a70e8beeb4"},"previous_names":["ljharb/system.global"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FglobalThis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FglobalThis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FglobalThis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/es-shims%2FglobalThis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/es-shims","download_url":"https://codeload.github.com/es-shims/globalThis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244868764,"owners_count":20523590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:01:07.468Z","updated_at":"2025-03-23T19:33:14.553Z","avatar_url":"https://github.com/es-shims.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ljharb","https://tidelift.com/funding/github/npm/es5-shim"],"categories":["JavaScript"],"sub_categories":[],"readme":"# globalThis \u003csup\u003e[![Version Badge][npm-version-svg]][npm-url]\u003c/sup\u003e\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![dependency status][deps-svg]][deps-url]\n[![dev dependency status][dev-deps-svg]][dev-deps-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][npm-url]\n\nAn ECMAScript spec-compliant polyfill/shim for `globalThis`. Invoke its \"shim\" method to shim `globalThis` if it is unavailable.\n\nThis 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).\n\nMost common usage:\n```js\nvar globalThis = require('globalthis')(); // returns native globalThis if compliant\n\t/* or */\nvar globalThis = require('globalthis/polyfill')(); // returns native globalThis if compliant\n```\n\n## Example\n\n```js\nvar assert = require('assert');\n\n// the below function is not CSP-compliant, but reliably gets the\n// global object in sloppy mode in every engine.\nvar getGlobal = Function('return this');\n\nassert.equal(globalThis, getGlobal());\n```\n\n```js\n/* when `globalThis` is not present */\nvar shimmedGlobal = require('globalthis').shim();\n\t/* or */\nvar shimmedGlobal = require('globalthis/shim')();\n\nassert.equal(shimmedGlobal, globalThis);\nassert.equal(shimmedGlobal, getGlobal());\n```\n\n```js\n/* when `globalThis` is present */\nvar shimmedGlobal = require('globalthis').shim();\n\nassert.equal(shimmedGlobal, globalThis);\nassert.equal(shimmedGlobal, getGlobal());\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[npm-url]: https://npmjs.org/package/globalthis\n[npm-version-svg]: https://versionbadg.es/ljharb/globalThis.svg\n[deps-svg]: https://david-dm.org/ljharb/globalThis.svg?theme=shields.io\n[deps-url]: https://david-dm.org/ljharb/globalThis\n[dev-deps-svg]: https://david-dm.org/ljharb/globalThis/dev-status.svg?theme=shields.io\n[dev-deps-url]: https://david-dm.org/ljharb/globalThis#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/globalthis.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/globalthis.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/globalthis.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=globalthis\n[codecov-image]: https://codecov.io/gh/es-shims/globalThis/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/es-shims/globalThis/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/globalThis\n[actions-url]: https://github.com/es-shims/globalThis/actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fes-shims%2FglobalThis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fes-shims%2FglobalThis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fes-shims%2FglobalThis/lists"}