11# Stream
22
3- Stability: 2 - Stable
3+ > Stability: 2 - Stable
44
55A stream is an abstract interface for working with streaming data in Node.js.
66The ` stream ` module provides a base API that makes it easy to build objects
@@ -20,7 +20,7 @@ const stream = require('stream');
2020```
2121
2222While it is important for all Node.js users to understand how streams works,
23- the ` stream ` module itself is most useful for developer's that are creating new
23+ the ` stream ` module itself is most useful for developers that are creating new
2424types of stream instances. Developer's who are primarily * consuming* stream
2525objects will rarely (if ever) have need to use the ` stream ` module directly.
2626
@@ -343,7 +343,7 @@ The buffered data will be flushed when either the [`stream.uncork()`][] or
343343[ ` stream.end() ` ] [ stream-end ] methods are called.
344344
345345The primary intent of ` writable.cork() ` is to avoid a situation where writing
346- many small chunks of data to a stream do not cause an backup in the internal
346+ many small chunks of data to a stream do not cause a backup in the internal
347347buffer that would have an adverse impact on performance. In such situations,
348348implementations that implement the ` writable._writev() ` method can perform
349349buffered writes in a more optimized manner.
@@ -411,7 +411,7 @@ If the `writable.cork()` method is called multiple times on a stream, the same
411411number of calls to ` writable.uncork() ` must be called to flush the buffered
412412data.
413413
414- ```
414+ ``` js
415415stream .cork ();
416416stream .write (' some ' );
417417stream .cork ();
@@ -444,7 +444,7 @@ first argument. To reliably detect write errors, add a listener for the
444444The return value indicates whether the written ` chunk ` was buffered internally
445445and the buffer has exceeded the ` highWaterMark ` configured when the stream was
446446created. If ` false ` is returned, further attempts to write data to the stream
447- should be paused until the ` 'drain' ` event is emitted.
447+ should be paused until the [ ` 'drain' ` ] [ ] event is emitted.
448448
449449A Writable stream in object mode will always ignore the ` encoding ` argument.
450450
@@ -676,7 +676,7 @@ rr.on('end', () => {
676676
677677The output of running this script is:
678678
679- ```
679+ ``` txt
680680$ node test.js
681681readable: null
682682end
@@ -1262,7 +1262,7 @@ write succeeded.
12621262It is important to note that all calls to ` writable.write() ` that occur between
12631263the time ` writable._write() ` is called and the ` callback ` is called will cause
12641264the written data to be buffered. Once the ` callback ` is invoked, the stream will
1265- emit a ` 'drain' ` event. If a stream implementation is capable of processing
1265+ emit a [ ` 'drain' ` ] [ ] event. If a stream implementation is capable of processing
12661266multiple chunks of data at once, the ` writable._writev() ` method should be
12671267implemented.
12681268
@@ -1554,7 +1554,7 @@ class Counter extends Readable {
15541554A [ Duplex] [ ] stream is one that implements both [ Readable] [ ] and [ Writable] [ ] ,
15551555such as a TCP socket connection.
15561556
1557- Because Javascript does not have support for multiple inheritance, the
1557+ Because JavaScript does not have support for multiple inheritance, the
15581558` stream.Duplex ` class is extended to implement a [ Duplex] [ ] stream (as opposed
15591559to extending the ` stream.Readable ` * and* ` stream.Writable ` classes).
15601560
@@ -1968,36 +1968,32 @@ readable buffer so there is nothing for a user to consume.
19681968[ `'end'` ] : #stream_event_end
19691969[ `'finish'` ] : #stream_event_finish
19701970[ `'readable'` ] : #stream_event_readable
1971- [ `buf.toString(encoding)` ] : https://nodejs.org/docs/v6.3.1/api/buffer.html#buffer_buf_tostring_encoding_start_end
1972- [ `EventEmitter` ] : https://nodejs.org/docs/v6.3.1/api/events.html#events_class_eventemitter
1973- [ `process.stderr` ] : https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stderr
1974- [ `process.stdin` ] : https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdin
1975- [ `process.stdout` ] : https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdout
1971+ [ `EventEmitter` ] : https://nodejs.org/docs/v6.4.0/api/events.html#events_class_eventemitter
1972+ [ `process.stderr` ] : https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stderr
1973+ [ `process.stdin` ] : https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdin
1974+ [ `process.stdout` ] : https://nodejs.org/docs/v6.4.0/api/process.html#process_process_stdout
19761975[ `stream.cork()` ] : #stream_writable_cork
19771976[ `stream.pipe()` ] : #stream_readable_pipe_destination_options
19781977[ `stream.uncork()` ] : #stream_writable_uncork
19791978[ `stream.unpipe()` ] : #stream_readable_unpipe_destination
19801979[ `stream.wrap()` ] : #stream_readable_wrap_stream
1981- [ `tls.CryptoStream` ] : https://nodejs.org/docs/v6.3.1/api/tls.html#tls_class_cryptostream
19821980[ API for Stream Consumers ] : #stream_api_for_stream_consumers
19831981[ API for Stream Implementers ] : #stream_api_for_stream_implementers
1984- [ child process stdin ] : https://nodejs.org/docs/v6.3.1 /api/child_process.html#child_process_child_stdin
1985- [ child process stdout and stderr ] : https://nodejs.org/docs/v6.3.1 /api/child_process.html#child_process_child_stdout
1982+ [ child process stdin ] : https://nodejs.org/docs/v6.4.0 /api/child_process.html#child_process_child_stdin
1983+ [ child process stdout and stderr ] : https://nodejs.org/docs/v6.4.0 /api/child_process.html#child_process_child_stdout
19861984[ Compatibility ] : #stream_compatibility_with_older_node_js_versions
19871985[ crypto ] : crypto.html
19881986[ Duplex ] : #stream_class_stream_duplex
1989- [ fs read streams ] : https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_readstream
1990- [ fs write streams ] : https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_writestream
1991- [ `fs.createReadStream()` ] : https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createreadstream_path_options
1992- [ `fs.createWriteStream()` ] : https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createwritestream_path_options
1993- [ `net.Socket` ] : https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
1994- [ `zlib.createDeflate()` ] : https://nodejs.org/docs/v6.3.1/api/zlib.html#zlib_zlib_createdeflate_options
1995- [ HTTP requests, on the client ] : https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_clientrequest
1996- [ HTTP responses, on the server ] : https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_serverresponse
1997- [ http-incoming-message ] : https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_incomingmessage
1998- [ Object mode ] : #stream_object_mode
1987+ [ fs read streams ] : https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_readstream
1988+ [ fs write streams ] : https://nodejs.org/docs/v6.4.0/api/fs.html#fs_class_fs_writestream
1989+ [ `fs.createReadStream()` ] : https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createreadstream_path_options
1990+ [ `fs.createWriteStream()` ] : https://nodejs.org/docs/v6.4.0/api/fs.html#fs_fs_createwritestream_path_options
1991+ [ `net.Socket` ] : https://nodejs.org/docs/v6.4.0/api/net.html#net_class_net_socket
1992+ [ `zlib.createDeflate()` ] : https://nodejs.org/docs/v6.4.0/api/zlib.html#zlib_zlib_createdeflate_options
1993+ [ HTTP requests, on the client ] : https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_clientrequest
1994+ [ HTTP responses, on the server ] : https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_serverresponse
1995+ [ http-incoming-message ] : https://nodejs.org/docs/v6.4.0/api/http.html#http_class_http_incomingmessage
19991996[ Readable ] : #stream_class_stream_readable
2000- [ SimpleProtocol v2 ] : #stream_example_simpleprotocol_parser_v2
20011997[ stream-_flush ] : #stream_transform_flush_callback
20021998[ stream-_read ] : #stream_readable_read_size_1
20031999[ stream-_transform ] : #stream_transform_transform_chunk_encoding_callback
@@ -2009,7 +2005,7 @@ readable buffer so there is nothing for a user to consume.
20092005[ stream-read ] : #stream_readable_read_size
20102006[ stream-resume ] : #stream_readable_resume
20112007[ stream-write ] : #stream_writable_write_chunk_encoding_callback
2012- [ TCP sockets ] : https://nodejs.org/docs/v6.3.1 /api/net.html#net_class_net_socket
2008+ [ TCP sockets ] : https://nodejs.org/docs/v6.4.0 /api/net.html#net_class_net_socket
20132009[ Transform ] : #stream_class_stream_transform
20142010[ Writable ] : #stream_class_stream_writable
20152011[ zlib ] : zlib.html
0 commit comments