-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Documentation/Add 'close' events to fs.ReadStream, fs.WriteStream, etc per Issue #6484 #6499
Changes from 5 commits
9d48b5d
ff217a8
827dfcb
57aa9e6
439df4b
b2a0db1
bcc8bd2
8cdf720
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,6 +151,10 @@ Stop watching for changes on the given `fs.FSWatcher`. | |
|
||
Emitted when the ReadStream's file is opened. | ||
|
||
### Event: 'close' | ||
|
||
Emitted when the ReadStream's underlying file descriptor has been closed. Comes from fs.close() method. | ||
|
||
### readStream.path | ||
|
||
The path to the file the stream is reading from as specified in the first | ||
|
@@ -238,6 +242,10 @@ on Unix systems, it never was. | |
|
||
Emitted when the WriteStream's file is opened. | ||
|
||
### Event: 'close' | ||
|
||
Emitted when the WriteStream's underlying file descriptor has been closed. Comes from fs.close() method. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nodejs/streams can we please check this? I thought |
||
|
||
### writeStream.bytesWritten | ||
|
||
The number of bytes written so far. Does not include data that is still queued | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,6 +572,12 @@ Examples of writable streams include: | |
* [TCP sockets][] | ||
* [child process stdin][] | ||
* [`process.stdout`][], [`process.stderr`][] | ||
|
||
#### Event: 'close' | ||
|
||
Emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed. The event indicates that no more events will be emitted, and no further computation will occur. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this differs from I will also move this block after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hesitate to move the 'Event: 'close'' block to after the 'Event: 'end'' block because these events seem to be in alphabetical order for better user experience. The difference between 'close' and 'end' events:
|
||
|
||
Not all streams will emit the `'close'` event. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will say this is an optional event for implementors. |
||
|
||
#### Event: 'drain' | ||
|
||
|
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 a "the" in front of
fs.close()
. Also, please putfs.close()
in backticks.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.
Suggested rewording (note also the addition of the backticks )
(same below for
WriteStream
also)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.
Is the note about
fs.close()
really that helpful/useful? Maybe we could just drop that part entirely?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'm good with it 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.
The reason I ask is because either way we're wording it makes it kind of sound like the end user is expected to call
fs.close()
/stream.close()
to see this event.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 do not think
'close'
is emitted only withfs.close()
, or am I wrong?