Skip to content

Conversation

@anentropic
Copy link
Contributor

I commented here: #20503 (comment)

Basically I found the current docs quite unclear about the behaviour of process.stdin, particularly with regards to reading a large file from stdin.

@mcollina suggested making a PR to improve the docs, so here is my attempt.

I have adjusted the code comments in the existing js example (as I found them misleading for my purposes). I have added a new paragraph, derived from @mcollina 's comment here #20503 (comment) to try to explain the actual behaviour. Finally I have added a second code example reflecting what I think is a more typical use case.

Please review these carefully for terminology and accuracy, I don't have much experience with node.js

Checklist

@nodejs-github-botnodejs-github-bot added doc Issues and PRs related to the documentations. process Issues and PRs related to the process subsystem. labels Apr 22, 2019
@BridgeARBridgeAR changed the title document more clearly that process.stdin will emit multiple readable eventsdoc: outline that process.stdin emits multiple readable eventsApr 22, 2019
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer we did not mention "old" stream mode in this docs. A user can add a 'data' event to start reading as well, it's part of the documented API.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is not something I added btw, I just moved it around. I'm happy to remove it though. Please be very specific about which part to remove or any alternative wording (I am just a casual node.js user so I don't have a good idea what is appropriate)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! let's keep the text for now.

@BridgeAR
Copy link
Member

@ronag PTAL

@ronag
Copy link
Member

Doesn’t this apply to streams in general? I haven’t looked at the specifics but if we’re changing anything shouldn’t that be in the streams docs?

@ronag
Copy link
Member

ronag commented Jan 12, 2020

i.e. I think any improvements should go into https://nodejs.org/dist/latest-v13.x/docs/api/stream.html#stream_readable_streams.

Unless there is something special about stdin I would suggest removing/moving the example from stdin doc, add more explicit link to streams documentation and maybe improve the stream docs with further examples and clarification.

@HarshithaKP
Copy link
Member

@anentropic, can you follow up with review comments ?

@anentropic
Copy link
ContributorAuthor

anentropic commented Mar 31, 2020

@anentropic, can you follow up with review comments ?

@HarshithaKP

re @Ronal's comments in January...

It looks to me that we should move/copy(?) the relevant parts of changed paragraph and example code from process.stdin to https://nodejs.org/dist/latest-v13.x/docs/api/stream.html#stream_readable_read_size where there is a very similar code example for readable.read()

Please confirm, and whether to move it or copy it

@HarshithaKP
Copy link
Member

Ping @ronag, I guess @anentropic miss spelled your name.

@ronag
Copy link
Member

ronag commented Apr 7, 2020

Please confirm, and whether to move it or copy it

I would personally prefer to move it and add a link in its place.

@anentropicanentropicforce-pushed the stdin-docs branch 5 times, most recently from 0a2de14 to dc6f8e8CompareApril 9, 2020 21:04
@anentropic
Copy link
ContributorAuthor

Hi all, thanks for your reviews and feedback. I have amended my changes, hopefully in line with everyone's preferences. Let me know any further tweaks needed.

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@BridgeARBridgeARforce-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72CompareMay 31, 2020 12:19
jasnell pushed a commit that referenced this pull request Jul 3, 2020
document more clearly that stdin will emit multiple readable events PR-URL: #27350 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

Landed in 7c9df66

@jasnelljasnell closed this Jul 3, 2020
MylesBorins pushed a commit that referenced this pull request Jul 14, 2020
document more clearly that stdin will emit multiple readable events PR-URL: #27350 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Jul 14, 2020
MylesBorins pushed a commit that referenced this pull request Jul 16, 2020
document more clearly that stdin will emit multiple readable events PR-URL: #27350 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Sep 22, 2020
document more clearly that stdin will emit multiple readable events PR-URL: #27350 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: James M Snell <[email protected]>
@codebyterecodebytere mentioned this pull request Sep 28, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docIssues and PRs related to the documentations.processIssues and PRs related to the process subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@anentropic@BridgeAR@ronag@HarshithaKP@jasnell@mcollina@nodejs-github-bot