Nerfing Powerful Megalomaniacs
Join us to discuss the challenges, solutions and best practices for in-house JavaScript code sharing. Tuesday, 12/17 at 10am PT/1pm ET.Sign up here »

@offirmo/globalthis-ponyfill

2.0.1 • Public • Published

globalThis ponyfill
Offirmo’s quality seal

npm badge dependencies badge bundle size badge license badge maintenance status badge

This is a trivial TypeScript-compatible globalThis ponyfill.

  • ~141b minified and gzipped
  • NO dependencies

Usage

import { getGlobalThis } from '@offirmo/globalthis-ponyfill'
 
const globalThis = getGlobalThis()

Rationale

There are existing ponyfills/polyfills out there, but they didn't work for me:

  • mine is much simpler: a single TS file of 6 meaningful lines
  • I needed TypeScript

Credits

YES I had a look at ljharb/globalThis's implementation (MIT) and started my implementation from it! Thanks a lot and all credits due!

About the proposed implementation here: https://mathiasbynens.be/notes/globalthis we can't use it: it creates a polyfill, not a ponyfill. However I took a line from the "naive implementation".

Install

npm i @offirmo/globalthis-ponyfill

DownloadsWeekly Downloads

24

Version

2.0.1

License

Unlicense

Unpacked Size

8.4 kB

Total Files

10

Last publish

Collaborators

  • avatar