-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
lib: add SafeSet.prototype.toUnsafeSet
#57723
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
Conversation
This should help with nodejs#57688 and others
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57723 +/- ##
=======================================
Coverage 90.22% 90.23%
=======================================
Files 630 630
Lines 185073 185079 +6
Branches 36222 36222
=======================================
+ Hits 166990 166998 +8
+ Misses 11044 11040 -4
- Partials 7039 7041 +2
🚀 New features to boost your workflow:
|
const set = new Set(); | ||
this.forEach((value) => primordials.SetPrototypeAdd(set, value)); | ||
return set; |
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.
Can we write tests that validates no user-code would be run? I think this can be simplified to
const set = new Set(); | |
this.forEach((value) => primordials.SetPrototypeAdd(set, value)); | |
return set; | |
return new Set(this); |
(given the triviality of the implementation, I wonder if it actually makes sense to add a method for that)
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.
Sure! I couldn't find anywhere SafeSet
is already tested, so i'm not sure where to add them - any suggestions?
I guess this is a valid simplification since it has a safe [Symbol.iterator]
on it, in which case you're right, it's probably not needed. I was assuming add-at-construction-time wasn't an option.
Closing, given #57723 (comment) |
This should help with #57688 and others.