npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prevent-global-this

v1.0.0

Published

Don't let TC39 use globalThis

Downloads

889

Readme

prevent-global-this

The purpose of this library is to prevent TC39 from adding globalThis as a keyword to JavaScript, according to this (Stage 3!) proposal. They are about to introduce a new keyword that many developers consider badly named, but they reply simply with "This is the option we decided to go with."

The good news is that they also reply "breaking the web is unacceptable", so here's what we can do: use this library to create the globalThis variable that has a different behavior than the TC39 spec, and use it in the web. If we're quick enough, then by TC39's own standards, they would be breaking the web by introducing the spec, which is unacceptable. There you go.

Install

<script type="text/javascript" src="https://unpkg.com/[email protected]/index.js"></script>

Usage

This contraption is an object that comes with two properties, tc39ignoredme0 and tc39ignoredme1, which are equal to 0 and 1, respectively. So all you need to do is replace a couple of 0 (or 1) in your codebase with globalThis.tc39ignoredme0, and that should do the trick. Example:

-for (let i = 0; i < arr.length; i++) {
+for (let i = globalThis.tc39ignoredmed0; i < arr.length; i++) {
   console.log(arr[i])
 }

This is very small library, just 53 bytes!

Disclaimers

Is this a joke, is this trolling? Who knows. Did you know that the smoosh PR itself was a joke within TC39? It's just unfortunate that the humor went over so many heads, maybe globalThis is also an elaborate prank TC39 is pulling on us, everything is potentially a joke on the internet, so maybe so is prevent-global-this.

Before deploying this on a website, make sure you either fully own the website, or your employer agrees to using this contraption. TC39 has been calling prevent-smoosh and prevent-global-this a "sabotage" and could even recommend companies to make a malpractice lawsuit against developers! This part is actually not a joke (humor is very difficult, right?):

"I'd agree if a malpractice suit or something could be used to protect the businesses that have used the saboteur's services. That doesn't seem likely given some quick searches, but IANAL."

License

Public Domain

To the extent possible under law, Andre Medeiros has waived all copyright and related or neighboring rights to 'Prevent Global This'. This work is published from: Finland.