-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement Set.isSubsetOf()
for Node <22, which defaults to builtin implementation whenever possible
#1009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't patch any prototype
s. Other libraries might expect builtin ES methods to work exactly to the letter of specification, and this implementation doesn't really look like it.
In case something goes wrong, we'll be up to hours of debug, because prototype
patching changes behavior of other code remotely and without any trace.
It would be much easier both for implementer and for future users to just define isSubsetOf
function, and optionally default it to builtin .isSubsetOf
method for increased performance on newer JS engines.
I should also mention that the concept of "polyfill" relies on the process around it. Polyfills are supplied by well-tested libraries, their authors are well-versed in spec legalese, and, most importantly, polyfills are applied by build infrastructure (for example, In this context neither the word "polyfill" nor its implementation appears as something end user might encounter in production codebase. At least not under regular circumstances. |
@verytactical I generally agree against prototype patching, but thought this particular case might be fine. Plus, I simply took the working polyfill from Web IDE repo. Which, I suppose, was in turn taken from core-js. Or not :) Anyways, I can re-write one or another implementation as a global function with optional fallback to the builtin method if/when it's present |
.isSubsetOf()
polyfillSet.isSubsetOf()
for Node <22, which defaults to builtin implementation whenever possible
Please, define it as a function. In case of WebIDE it's apparently either used in one of the libraries, or not used at all. Probably it's there, because it compiles code with |
47ed53c
to
84f7082
Compare
@verytactical all good now — the function is global, but your introduction of UPD: Turns out we do have the |
Which was used already in `scripts/pack.ts`
0cfc84c
to
80f4edc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I should stop bikeshedding this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Issue
Closes #1008.
Checklist