
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
The globalthis npm package provides a polyfill for the global `globalThis` object, which is a standard way to access the global object (e.g., `window` in browsers, `global` in Node.js) in a universal manner across different JavaScript environments. This package ensures that you can reliably use `globalThis` in environments where it might not be natively supported.
Polyfill for globalThis
This code snippet demonstrates how to polyfill the global `globalThis` object using the globalthis package. After requiring and invoking the package, you can reliably use `globalThis` in your code to refer to the global object.
require('globalthis')(); // This will polyfill globalThis if it doesn't exist
core-js is a modular standard library for JavaScript, which includes polyfills for ECMAScript up to the latest standards. It provides more comprehensive polyfills than globalthis, including polyfills for `globalThis`. It is more feature-rich but also larger in size compared to the focused functionality of globalthis.
es6-shim is a shim that provides compatibility shims so that legacy JavaScript engines behave as closely as possible to ECMAScript 6 (Harmony). It includes a polyfill for `globalThis` among many other features. Like core-js, it is more extensive than globalthis but also more heavyweight.
An ECMAScript spec-compliant polyfill/shim for globalThis
. Invoke its "shim" method to shim globalThis
if it is unavailable.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec proposal.
Most common usage:
var globalThis = require('globalthis')(); // returns native globalThis if compliant
/* or */
var globalThis = require('globalthis/polyfill')(); // returns native globalThis if compliant
var assert = require('assert');
// the below function is not CSP-compliant, but reliably gets the
// global object in sloppy mode in every engine.
var getGlobal = Function('return this');
assert.equal(globalThis, getGlobal());
/* when `globalThis` is not present */
var shimmedGlobal = require('globalthis').shim();
/* or */
var shimmedGlobal = require('globalthis/shim')();
assert.equal(shimmedGlobal, globalThis);
assert.equal(shimmedGlobal, getGlobal());
/* when `globalThis` is present */
var shimmedGlobal = require('globalthis').shim();
assert.equal(shimmedGlobal, globalThis);
assert.equal(shimmedGlobal, getGlobal());
Simply clone the repo, npm install
, and run npm test
v1.0.4 - 2024-04-29
280d796
gopd
0209ccb
c08aea6
@es-shims/api
, @ljharb/eslint-config
, aud
, tape
f38f2af
aud
, tape
a1be102
define-properties
3e41644
define-properties
3d81f70
npmignore
dep c2d00f7
FAQs
ECMAScript spec-compliant polyfill/shim for `globalThis`
The npm package globalthis receives a total of 23,333,585 weekly downloads. As such, globalthis popularity was classified as popular.
We found that globalthis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.