-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
[x] stream: add bytesRead to Readable #27988
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
cb19bd2 to
e82d510
Compare
addaleax
left a 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.
Some notes:
- In other places in core (e.g.
net.Socket), we track the same thing and call itbytesRead(although I think it may vary in case of.setEncoding()being used) - For Writables, there’s
bytesWrittenin that case, which might also be interesting if we do want this at the streams level
675cb94 to
ae8b600
Compare
|
Also, tests should be added for this. |
|
|
I agree with @addaleax that |
|
Updated |
ae8b600 to
86dacd2
Compare
BridgeAR
left a 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.
LGTM with a test added.
|
cc @nodejs/streams |
mcollina
left a 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.
Tests are needed.
Overall I would prefer a generic API that works with both object mode and non-object mode streams.
86dacd2 to
049315f
Compare
|
@mcollina sorry for delay, how about now? |
mcollina
left a 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.
Can you add bytesWritten as well for simmetry?
f55d84b to
a39ffd1
Compare
|
@mcollina done |
mcollina
left a 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.
This needs unit tests.
|
Ping @ronag ... this PR needs tests in order to proceed. |
|
This is blocked by #28004. In regards to some questions about naming and |
|
I'm closing this for now. |
It's a somewhat common scenario to be able to keep track of number of bytes that has been read from a stream. The only way to achieve this in user land will cause either complexity or performance overhead.
Adding it into core would be somewhat untrivial both in terms of complexity and performance.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes