You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,10 +91,16 @@ There's a holy-moly-lot of events that go on with streams. How do you know which
91
91
Sometimes, you won't even know what kind of stream you have. Libraries may give you combined/duplex streams, a Transform stream, or a plain old readable stream. You really have to stay close to their documentation and source code to see what you're dealing with.
92
92
93
93
**Solution**
94
-
-`abort()` - This is a method called on request streams ([`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback), [`request`](http://gitnpm.com/request)) that aborts the request.
95
-
-`.on('close')` event - Not always present. Readable streams emit this when the underlying resource is closed. Ex: a socket or a file that was "opened" to be read from.
96
-
-`.on('complete')` - This is a custom event from [`request`](http://gitnpm.com/request) to indicate the request is completed.
97
-
-`destroy([err])` - Destroy can be called on most new, non-core streams as a less-patient version of calling `end()`. The stream will be "destroyed" without a care to any data that hasn't been processed yet. Usually, an error can be given that will be emitted to the error event for the stream.
98
-
-`end()` - This is a method that can be called on all streams that are writable to gracefully end the stream. Any remaining data that hasn't been written yet will be allowed to be drained. For readable streams, doing `readStream.push(null)` will end the stream and emit the `end` event.
99
-
-`.on('end')` - All readable streams emit "end" when all of the data is read from. This in turn calls the `end()` method on its destination stream, letting it know "what you have left to write is all you have to worry about, buddy".
100
-
-`.on('finish')` - All streams that are writable emit "finish" when all of the data has been written to their destination.
94
+
95
+
Events | Description
96
+
---------|------------
97
+
close | Not always emitted. Readable streams emit this when the underlying resource is closed. Ex: a socket or a file that was "opened" to be read from.
98
+
complete | This is a custom event from [`request`](http://gitnpm.com/request) to indicate the request is completed.
99
+
end | All readable streams emit "end" when all of the data is read from. This in turn calls the `end()` method on its destination stream, letting it know "what you have left to write is all you have to worry about, buddy".
100
+
finish | All streams that are writable emit "finish" when all of the data has been written to their destination.
101
+
102
+
Methods | Description
103
+
---------------|------------
104
+
abort() | This is a method called on request streams ([`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback), [`request`](http://gitnpm.com/request)) that aborts the request.
105
+
destroy([err]) | Destroy can be called on most new, non-core streams as a less-patient version of calling `end()`. The stream will be "destroyed" without a care to any data that hasn't been processed yet. Usually, an error can be given that will be emitted to the error event for the stream.
106
+
end() | This is a method that can be called on all streams that are writable to gracefully end the stream. Any remaining data that hasn't been written yet will be allowed to be drained. For readable streams, doing `readStream.push(null)` will end the stream and emit the `end` event.
0 commit comments