-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
zlib: use new.target to check for instantiation #54694
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #54694 +/- ##
==========================================
+ Coverage 87.33% 87.60% +0.27%
==========================================
Files 650 650
Lines 182832 182843 +11
Branches 35067 35384 +317
==========================================
+ Hits 159670 160180 +510
+ Misses 16421 15929 -492
+ Partials 6741 6734 -7
|
7c70f41
to
e7449c4
Compare
@nodejs/tsc this is a semver-major because the removed test is broken. |
e7449c4
to
1af1c3b
Compare
1af1c3b
to
e74e917
Compare
@@ -706,57 +706,64 @@ Zlib.prototype.params = function params(level, strategy, callback) { | |||
// generic zlib | |||
// minimal 2-byte header | |||
function Deflate(opts) { | |||
if (!(this instanceof Deflate)) | |||
if (!new.target) { |
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.
if (!new.target) { | |
if (new.target !== Deflate) { |
if you also want to normalize subclasses
Is this more performant? Would it work with subclasses? |
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.
That seems like something we would want to support, at least using ES6 class syntax
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.
With the ES6 syntax this test would still pass (except if doing #54694 (comment)).
I guess this change only makes sense if done together with #54676, since this is about detecting when new
is used or not.
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'm -1, we should keep supporting the removed test
Referring to @nicolo-ribaudo's comment: #54676 (comment)