-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
writeable stream: group all properties #31187
Conversation
52819a8
to
88f20ec
Compare
lib/_stream_writable.js
Outdated
if (this._writableState === undefined) { | ||
return false; | ||
destroyed: { | ||
enumerable: false, |
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 ObjectDefineProperties
defaults enumerable
to false, so I don't think these are needed? I'm not sure I understand the above comment about making it explicit? @BridgeAR any idea who is the original author of this comment?
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.
@ronag: That's a good point. I guess we no need to add these properties. For example, I tested the below code and by default the enumerable property is false
:
const a = {}
Object.defineProperties(a, { test: { get() { return 'test'} } })
a.test // test
a.propertyIsEnumerable('test') // false
Edit: Guess you have wrongly pinged instead of me :)
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.
Seems like that was Calvin. Some people prefer explicit descriptor properties. Probably because not everyone is handling descriptors frequently and knows that their defaults are all false
. It should be fine either way.
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.
As this also came up in #31287 (comment):
I think it’s better to be explicit here, regardless of what people may know about the default values; partly because it removes cognitive overhead of figuring out what the behaviour is, partly because making it explicit forces code authors to be deliberate about the values they choose.
88f20ec
to
ad4b942
Compare
@ronag Done. @lpinca: Removed enumerable definition as mentioned here: #31187 (comment) Could you PTAL again? |
lib/_stream_writable.js
Outdated
@@ -198,7 +199,7 @@ ObjectDefineProperty(WritableState.prototype, 'buffer', { | |||
get: internalUtil.deprecate(function writableStateBufferGetter() { | |||
return this.getBuffer(); | |||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + | |||
'instead.', 'DEP0003') | |||
'instead.', 'DEP0003') |
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.
Accidental change?
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.
LGTM
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.
Still LGTM with nits addressed.
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.
LGTM with the comments addressed.
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.
Pile-on "LGTM with nits addressed"
PR-URL: #31236 Refs: #31187 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Ping @antsmartian |
Sorry for delay, taken care the comments.. cc @BridgeAR @nodejs/streams |
PR-URL: #31236 Refs: #31187 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@antsmartian Can you sqaush the commits here together? CI detects a merge conflict in one of the earlier ones that is then resolved later, but it still fails to rebase because of that. (Also happy to do that for you if you prefer.) |
Another property |
2f226c8
to
5494213
Compare
5494213
to
36c6219
Compare
@addaleax PTAL.. This should be fine now. |
Landed in 0ac04ec 🙂 |
PR-URL: #31187 Refs: #31144 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Hey All, this doesn't land cleanly on v13.x should there be a backport? |
A backport will be good to have to avoid future conflicts. |
PR-URL: nodejs#31187 Refs: nodejs#31144 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Backport-PR-URL: nodejs#32164
Backport-PR-URL: #32164 PR-URL: #31187 Refs: #31144 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #31236 Refs: #31187 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Backport-PR-URL: #32164 PR-URL: #31187 Refs: #31144 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Refs: #31144 for writable streams.
cc @nodejs/streams
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes