lib: add SafeSet.prototype.toUnsafeSet#57723
Conversation
This should help with nodejs#57688 and others
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
🚀 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.
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.
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.