1
1
# Stream
2
2
3
- Stability: 2 - Stable
3
+ > Stability: 2 - Stable
4
4
5
5
A stream is an abstract interface for working with streaming data in Node.js.
6
6
The ` stream ` module provides a base API that makes it easy to build objects
@@ -20,7 +20,7 @@ const stream = require('stream');
20
20
```
21
21
22
22
While 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
24
24
types of stream instances. Developer's who are primarily * consuming* stream
25
25
objects will rarely (if ever) have need to use the ` stream ` module directly.
26
26
@@ -343,7 +343,7 @@ The buffered data will be flushed when either the [`stream.uncork()`][] or
343
343
[ ` stream.end() ` ] [ stream-end ] methods are called.
344
344
345
345
The 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
347
347
buffer that would have an adverse impact on performance. In such situations,
348
348
implementations that implement the ` writable._writev() ` method can perform
349
349
buffered writes in a more optimized manner.
@@ -411,7 +411,7 @@ If the `writable.cork()` method is called multiple times on a stream, the same
411
411
number of calls to ` writable.uncork() ` must be called to flush the buffered
412
412
data.
413
413
414
- ```
414
+ ``` js
415
415
stream .cork ();
416
416
stream .write (' some ' );
417
417
stream .cork ();
@@ -444,7 +444,7 @@ first argument. To reliably detect write errors, add a listener for the
444
444
The return value indicates whether the written ` chunk ` was buffered internally
445
445
and the buffer has exceeded the ` highWaterMark ` configured when the stream was
446
446
created. 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.
448
448
449
449
A Writable stream in object mode will always ignore the ` encoding ` argument.
450
450
@@ -676,7 +676,7 @@ rr.on('end', () => {
676
676
677
677
The output of running this script is:
678
678
679
- ```
679
+ ``` txt
680
680
$ node test.js
681
681
readable: null
682
682
end
@@ -1262,7 +1262,7 @@ write succeeded.
1262
1262
It is important to note that all calls to ` writable.write() ` that occur between
1263
1263
the time ` writable._write() ` is called and the ` callback ` is called will cause
1264
1264
the 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
1266
1266
multiple chunks of data at once, the ` writable._writev() ` method should be
1267
1267
implemented.
1268
1268
@@ -1554,7 +1554,7 @@ class Counter extends Readable {
1554
1554
A [ Duplex] [ ] stream is one that implements both [ Readable] [ ] and [ Writable] [ ] ,
1555
1555
such as a TCP socket connection.
1556
1556
1557
- Because Javascript does not have support for multiple inheritance, the
1557
+ Because JavaScript does not have support for multiple inheritance, the
1558
1558
` stream.Duplex ` class is extended to implement a [ Duplex] [ ] stream (as opposed
1559
1559
to extending the ` stream.Readable ` * and* ` stream.Writable ` classes).
1560
1560
@@ -1968,36 +1968,32 @@ readable buffer so there is nothing for a user to consume.
1968
1968
[ `'end'` ] : #stream_event_end
1969
1969
[ `'finish'` ] : #stream_event_finish
1970
1970
[ `'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
1976
1975
[ `stream.cork()` ] : #stream_writable_cork
1977
1976
[ `stream.pipe()` ] : #stream_readable_pipe_destination_options
1978
1977
[ `stream.uncork()` ] : #stream_writable_uncork
1979
1978
[ `stream.unpipe()` ] : #stream_readable_unpipe_destination
1980
1979
[ `stream.wrap()` ] : #stream_readable_wrap_stream
1981
- [ `tls.CryptoStream` ] : https://nodejs.org/docs/v6.3.1/api/tls.html#tls_class_cryptostream
1982
1980
[ API for Stream Consumers ] : #stream_api_for_stream_consumers
1983
1981
[ 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
1986
1984
[ Compatibility ] : #stream_compatibility_with_older_node_js_versions
1987
1985
[ crypto ] : crypto.html
1988
1986
[ 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
1999
1996
[ Readable ] : #stream_class_stream_readable
2000
- [ SimpleProtocol v2 ] : #stream_example_simpleprotocol_parser_v2
2001
1997
[ stream-_flush ] : #stream_transform_flush_callback
2002
1998
[ stream-_read ] : #stream_readable_read_size_1
2003
1999
[ stream-_transform ] : #stream_transform_transform_chunk_encoding_callback
@@ -2009,7 +2005,7 @@ readable buffer so there is nothing for a user to consume.
2009
2005
[ stream-read ] : #stream_readable_read_size
2010
2006
[ stream-resume ] : #stream_readable_resume
2011
2007
[ 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
2013
2009
[ Transform ] : #stream_class_stream_transform
2014
2010
[ Writable ] : #stream_class_stream_writable
2015
2011
[ zlib ] : zlib.html
0 commit comments