-
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
'data' argument on callback of Transform._flush() #3708
Conversation
@piranna If you are submitting a pull request that adds new functionality, please include one or more tests for the new functionality. |
cc @nodejs/streams |
-1 personally, at least until the use case is explained. The linked issue does not give any reason why this would be a good API change. |
@domenic consistency it's a bit of a footgun that the callback takes the second argument one place and not another, I'm frankly surprised I haven't run into it myself, does need a test though @piranna take a look at the tests marked stream in this folder which would be where a test for this would go. |
As @calvinmetcalf says, consistency is the main reason. Yesterday I was doing a Transform and found that I'm currently connected on my cell phone, I'll do the tests tomorrow when I get home. |
Ah, ignore my previous comment, I see it now. |
As said before, consistency. This transform do nothing for each chunk, but the docs says you can pass data for it on this callback inside _transform(), so someone would think intuitively that it's also possible on this callback inside _flush() but the fact is that's currently not possible. Why I need to call to |
Hmm.. technically there's nothing wrong with the change and I'm not going to give it a -1, but I'm in agreement that consistency in this case does not seem to be a strong enough argument. As far as I can tell, the reason |
Well, I was going to because intuitively it should work, until I get to the fact that it was not implemented... :-/ (sorry for not adding the tests yet, I'm really busy lately, but didn't forgot about this) |
OK that's fair :) out of curiosity, are you able to share the details of
|
Yes, as you can see these two lines would be implemented as only one. Not too much an issue, but you would expect that's possible to do... |
Ok. I don't have time to do a technical review at the moment, but could I ask that you please take a moment to expand on the reasons for the change in the commit log message itself? It would be helpful. Thank you! |
see here for the commit message format |
@piranna ... still interested in pursuing this? |
Hi @jasnell, I'm still interested on this, only that I got attention on other issues. I'll try to do the pull-request this afternoon. |
I've just added the missing test and also added a reference to the new |
@nodejs/ctc ... thoughts? |
|
||
t.end(Buffer.from('blerg')); | ||
t.on('data', function(data) | ||
{ |
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.
mind not dropping the {
to the next line?
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.
Sorry, I'm used to Allman style here :-P Fixed :-)
Adding for API consistency sounds good. Besides the comment I'd also like the commits squashed and a description of the issue in the commit message body. Then add the metadata:
at the bottom of the message body. Those things addressed, LGTM |
Commits squashed, and description and commit metadata added :-) |
@@ -0,0 +1,24 @@ | |||
'use strict'; | |||
var assert = require('assert'); | |||
var Transform = require('stream').Transform; |
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 add const common = require('../common')
as the first require, and make these const
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.
Done... although common
is not used anywhere :-/
Left some comments. With those addressed LGTM |
Done. I've seen that there are conflicts, should I rebase with |
Great and yes :). |
Add a `data` argument on Transform._flush() callback to be API consistent with Transform._transform(). Fixes: nodejs#3707
Done :-)
Me too! I'm from Spain :-) Are you from Italy, maybe? ;-) |
@piranna I'm merging now, but I see deps/npm/node_modules/npm-registry-client/node_modules/concat-stream/node_modules/readable-stream/doc/stream.markdown If it's ok for you, I'll just avoid that change in this case.
|
As you see it fits, I did that change to update the API docs, no more.
|
I don't think that's the right file to change, https://github.com/nodejs/node/blob/master/doc/api/stream.md is. |
Landed as 0cd0118. |
This fixes issue #3707