Skip to content

atypiape/polyfill-global-this

Repository files navigation

Polyfill-Global-This

A polyfill for globalThis in runtimes that don't support it. Just need to import the library at the top of the code entry.


向不支持 globalThis 的运行环境,全局注入 globalThis。只需在代码入口的顶部导入这个库。

Usage

NPM

npm i polyfill-global-this

YARN

yarn add polyfill-global-this

Example

import 'polyfill-global-this';

// globalThis is now available
console.log(typeof globalThis);

// in browser, globalThis is the same as window
console.log(globalThis === window);

// in Node.js, globalThis is the same as global
console.log(globalThis === global);

// in React Native and browser, globalThis is the same as self
console.log(globalThis === self);

About

Global property globalThis polyfill

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published