@offirmo/globalthis-ponyfill
Ponyfill for globalThis
Last updated 4 years ago by offirmo .
Unlicense · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @offirmo/globalthis-ponyfill 
SYNC missed versions from official npm registry.

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.

  • very small minzipped size
  • NO dependencies
  • doesn't alter the environment (ponyfill)
  • compatible with node & browser

Usage

import { getGlobalThis } from '@offirmo/globalthis-ponyfill'

// typed access
declare global {
	var foo: number
}
const globalThis = getGlobalThis()
globalThis.foo = 42

// untyped access
const globalThis = getGlobalThis<any>()
globalThis.bar = 42

Rationale

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".

Current Tags

  • 4.0.0                                ...           latest (4 years ago)

13 Versions

  • 4.0.0                                ...           4 years ago
  • 3.0.2                                ...           5 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Total 12
Today 2
This Week 9
This Month 10
Last Day 7
Last Week 1
Last Month 0
Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE