Giter VIP home page Giter VIP logo

prevent-global-this's Introduction

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.tc39ignoredme0; 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.

prevent-global-this's People

Contributors

ajaegle avatar staltz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ajaegle anurbol

prevent-global-this's Issues

Alternatives?

It would be much better if readme showed some examples of what could really be used instead of globalThis. Just rejecting something without suggesting another option is never good. The current state of this repo feels like it just makes the life harder for the TC39 committee.

This is not very constructive

Please, instead of providing a library that intentionally breaks the web, use your reach to make people participate on the discussion. If we can make W3C aware that the majority of JS developers dislikes the globalThis they might reconsider it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.