Skip to content

doc: outline that process.stdin emits multiple readable events - #27350

Closed
anentropic wants to merge 2 commits into
nodejs:masterfrom
anentropic:stdin-docs
Closed

doc: outline that process.stdin emits multiple readable events#27350
anentropic wants to merge 2 commits into
nodejs:masterfrom
anentropic:stdin-docs

Conversation

@anentropic

Copy link
Copy Markdown
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
Comment threaddoc/api/process.md Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
Member

@ronag PTAL

@ronag

Copy link
Copy Markdown
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

ronag commented Jan 12, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@anentropic, can you follow up with review comments ?

Comment threaddoc/api/process.md Outdated
@anentropic

anentropic commented Mar 31, 2020

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Member

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

@ronag

ronag commented Apr 7, 2020

Copy link
Copy Markdown
Member

Please confirm, and whether to move it or copy it

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

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

Copy link
Copy Markdown
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.

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment threaddoc/api/stream.md Outdated
@BridgeAR
BridgeARforce-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 <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell

Copy link
Copy Markdown
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 <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@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 <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
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 <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@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