@@ -38,7 +38,7 @@ There are four fundamental stream types within Node.js: |
38 | 38 | * [Readable][] - streams from which data can be read (for example |
39 | 39 | [`fs.createReadStream()`][]). |
40 | 40 | * [Writable][] - streams to which data can be written (for example |
41 | | - [`fs.createWriteStream`][]). |
| 41 | + [`fs.createWriteStream()`][]). |
42 | 42 | * [Duplex][] - streams that are both Readable and Writable (for example |
43 | 43 | [`net.Socket`][]). |
44 | 44 | * [Transform][] - Duplex streams that can modify or transform the data as it |
@@ -77,7 +77,7 @@ queue until it is consumed. |
77 | 77 | Once the total size of the internal read buffer reaches the threshold specified |
78 | 78 | by `highWaterMark`, the stream will temporarily stop reading data from the |
79 | 79 | underlying resource until the data currently buffered can be consumed (that is, |
80 | | -the stream will stop calling the internal `readable.\_read()` method that is |
| 80 | +the stream will stop calling the internal `readable._read()` method that is |
81 | 81 | used to fill the read buffer). |
82 | 82 |
|
83 | 83 | Data is buffered in Writable streams when the |
@@ -321,7 +321,7 @@ The buffered data will be flushed when either the [`stream.uncork()`][] or |
321 | 321 | The primary intent of `writable.cork()` is to avoid a situation where writing |
322 | 322 | many small chunks of data to a stream do not cause an backup in the internal |
323 | 323 | buffer that would have an adverse impact on performance. In such situations, |
324 | | -implementations that implement the `writable.\_writev()` method can perform |
| 324 | +implementations that implement the `writable._writev()` method can perform |
325 | 325 | buffered writes in a more optimized manner. |
326 | 326 |
|
327 | 327 | ##### writable.end([chunk][, encoding][, callback]) |
@@ -786,7 +786,7 @@ following example: |
786 | 786 |
|
787 | 787 | ```js |
788 | 788 | getReadableStreamSomehow() |
789 | | - .resume(); |
| 789 | + .resume() |
790 | 790 | .on('end', () => { |
791 | 791 | console.log('Reached the end, but did not read anything.'); |
792 | 792 | }); |
@@ -1083,8 +1083,8 @@ const myWritable = new Writable({ |
1083 | 1083 | The `stream.Writable` class is extended to implement a [Writable][] stream. |
1084 | 1084 |
|
1085 | 1085 | Custom Writable streams *must* call the `new stream.Writable([options])` |
1086 | | -constructor and implement the `writable.\_write()` method. The |
1087 | | -`writable.\_writev()` method *may* also be implemented. |
| 1086 | +constructor and implement the `writable._write()` method. The |
| 1087 | +`writable._writev()` method *may* also be implemented. |
1088 | 1088 |
|
1089 | 1089 | #### Constructor: new stream.Writable([options]) |
1090 | 1090 |
|
@@ -1161,7 +1161,7 @@ All Writable stream implementations must provide a |
1161 | 1161 | resource. |
1162 | 1162 |
|
1163 | 1163 | *Note*: [Transform][] streams provide their own implementation of the |
1164 | | -[`writable._write()`]. |
| 1164 | +[`writable._write()`][stream-_write]. |
1165 | 1165 |
|
1166 | 1166 | *Note*: **This function MUST NOT be called by application code directly.** It |
1167 | 1167 | should be implemented by child classes, and called only by the internal Writable |
@@ -1173,10 +1173,10 @@ successfully or failed with an error. The first argument passed to the |
1173 | 1173 | write succeeded. |
1174 | 1174 |
|
1175 | 1175 | It is important to note that all calls to `writable.write()` that occur between |
1176 | | -the time `writable.\_write()` is called and the `callback` is called will cause |
| 1176 | +the time `writable._write()` is called and the `callback` is called will cause |
1177 | 1177 | the written data to be buffered. Once the `callback` is invoked, the stream will |
1178 | 1178 | emit a `'drain'` event. If a stream implementation is capable of processing |
1179 | | -multiple chunks of data at once, the `writable.\_writev()` method should be |
| 1179 | +multiple chunks of data at once, the `writable._writev()` method should be |
1180 | 1180 | implemented. |
1181 | 1181 |
|
1182 | 1182 | If the `decodeStrings` property is set in the constructor options, then |
@@ -1187,7 +1187,7 @@ data encodings. If the `decodeStrings` property is explicitly set to `false`, |
1187 | 1187 | the `encoding` argument can be safely ignored, and `chunk` will always be a |
1188 | 1188 | `Buffer`. |
1189 | 1189 |
|
1190 | | -The `writable.\_write()` method is prefixed with an underscore because it is |
| 1190 | +The `writable._write()` method is prefixed with an underscore because it is |
1191 | 1191 | internal to the class that defines it, and should never be called directly by |
1192 | 1192 | user programs. |
1193 | 1193 |
|
@@ -1202,22 +1202,22 @@ user programs. |
1202 | 1202 | should be implemented by child classes, and called only by the internal Writable |
1203 | 1203 | class methods only. |
1204 | 1204 |
|
1205 | | -The `writable.\_writev()` method may be implemented in addition to |
1206 | | -`writable.\_write()` in stream implementations that are capable of processing |
| 1205 | +The `writable._writev()` method may be implemented in addition to |
| 1206 | +`writable._write()` in stream implementations that are capable of processing |
1207 | 1207 | multiple chunks of data at once. If implemented, the method will be called with |
1208 | 1208 | all chunks of data currently buffered in the write queue. |
1209 | 1209 |
|
1210 | | -The `writable.\_writev()` method is prefixed with an underscore because it is |
| 1210 | +The `writable._writev()` method is prefixed with an underscore because it is |
1211 | 1211 | internal to the class that defines it, and should never be called directly by |
1212 | 1212 | user programs. |
1213 | 1213 |
|
1214 | 1214 | #### Errors While Writing |
1215 | 1215 |
|
1216 | 1216 | It is recommended that errors occurring during the processing of the |
1217 | | -`writable.\_write()` and `writable.\_writev()` methods are reported by invoking |
| 1217 | +`writable._write()` and `writable._writev()` methods are reported by invoking |
1218 | 1218 | the callback and passing the error as the first argument. This will cause an |
1219 | 1219 | `'error'` event to be emitted by the Writable. Throwing an Error from within |
1220 | | -`writable.\_write()` can result in expected and inconsistent behavior depending |
| 1220 | +`writable._write()` can result in expected and inconsistent behavior depending |
1221 | 1221 | on how the stream is being used. Using the callback ensures consistent and |
1222 | 1222 | predictable handling of errors. |
1223 | 1223 |
|
@@ -1265,7 +1265,7 @@ class MyWritable extends Writable { |
1265 | 1265 | The `stream.Readable` class is extended to implement a [Readable][] stream. |
1266 | 1266 |
|
1267 | 1267 | Custom Readable streams *must* call the `new stream.Readable([options])` |
1268 | | -constructor and implement the `readable.\_read()` method. |
| 1268 | +constructor and implement the `readable._read()` method. |
1269 | 1269 |
|
1270 | 1270 | #### new stream.Readable([options]) |
1271 | 1271 |
|
@@ -1329,7 +1329,7 @@ should be implemented by child classes, and called only by the internal Readable |
1329 | 1329 | class methods only. |
1330 | 1330 |
|
1331 | 1331 | All Readable stream implementations must provide an implementation of the |
1332 | | -`readable.\_read()` method to fetch data from the underlying resource. |
| 1332 | +`readable._read()` method to fetch data from the underlying resource. |
1333 | 1333 |
|
1334 | 1334 | When `readable._read()` is called, if data is available from the resource, the |
1335 | 1335 | implementation should begin pushing that data into the read queue using the |
@@ -1347,7 +1347,7 @@ much data to fetch. Other implementations may ignore this argument and simply |
1347 | 1347 | provide data whenever it becomes available. There is no need to "wait" until |
1348 | 1348 | `size` bytes are available before calling [`stream.push(chunk)`][stream-push]. |
1349 | 1349 |
|
1350 | | -The `readable.\_read()` method is prefixed with an underscore because it is |
| 1350 | +The `readable._read()` method is prefixed with an underscore because it is |
1351 | 1351 | internal to the class that defines it, and should never be called directly by |
1352 | 1352 | user programs. |
1353 | 1353 |
|
@@ -1407,13 +1407,13 @@ class SourceWrapper extends Readable { |
1407 | 1407 | } |
1408 | 1408 | ``` |
1409 | 1409 | *Note*: The `readable.push()` method is intended be called only by Readable |
1410 | | -Implemeters, and only from within the `readable.\_read()` method. |
| 1410 | +Implemeters, and only from within the `readable._read()` method. |
1411 | 1411 |
|
1412 | 1412 | #### Errors While Reading |
1413 | 1413 |
|
1414 | 1414 | It is recommended that errors occurring during the processing of the |
1415 | | -`readable.\_read()` method are emitted using the `'error'` event rather than |
1416 | | -being thrown. Throwing an Error from within `readable.\_read()` can result in |
| 1415 | +`readable._read()` method are emitted using the `'error'` event rather than |
| 1416 | +being thrown. Throwing an Error from within `readable._read()` can result in |
1417 | 1417 | expected and inconsistent behavior depending on whether the stream is operating |
1418 | 1418 | in flowing or paused mode. Using the `'error'` event ensures consistent and |
1419 | 1419 | predictable handling of errors. |
@@ -1475,8 +1475,8 @@ to extending the `stream.Readable` *and* `stream.Writable` classes). |
1475 | 1475 | and parasitically from `stream.Writable`. |
1476 | 1476 |
|
1477 | 1477 | Custom Duplex streams *must* call the `new stream.Duplex([options])` |
1478 | | -constructor and implement *both* the `readable.\_read()` and |
1479 | | -`writable.\_write()` methods. |
| 1478 | +constructor and implement *both* the `readable._read()` and |
| 1479 | +`writable._write()` methods. |
1480 | 1480 |
|
1481 | 1481 | #### new stream.Duplex(options) |
1482 | 1482 |
|
@@ -1629,10 +1629,10 @@ that is either much smaller or much larger than its input. |
1629 | 1629 | The `stream.Transform` class is extended to implement a [Transform][] stream. |
1630 | 1630 |
|
1631 | 1631 | The `stream.Transform` class prototypically inherits from `stream.Duplex` and |
1632 | | -implements its own versions of the `writable.\_write()` and `readable.\_read()` |
| 1632 | +implements its own versions of the `writable._write()` and `readable._read()` |
1633 | 1633 | methods. Custom Transform implementations *must* implement the |
1634 | | -[`transform.\_transform()`][stream-_transform] method and *may* also implement |
1635 | | -the [`transform.\_flush()`][stream-._flush] method. |
| 1634 | +[`transform._transform()`][stream-_transform] method and *may* also implement |
| 1635 | +the [`transform._flush()`][stream-_flush] method. |
1636 | 1636 |
|
1637 | 1637 | *Note*: Care must be taken when using Transform streams in that data written |
1638 | 1638 | to the stream can cause the Writable side of the stream to become paused if |
@@ -1709,16 +1709,16 @@ store an amount of internal state used to optimally compress the output. When |
1709 | 1709 | the stream ends, however, that additional data needs to be flushed so that the |
1710 | 1710 | compressed data will be complete. |
1711 | 1711 |
|
1712 | | -Custom [Transform][] implementations *may* implement the `transform.\_flush()` |
| 1712 | +Custom [Transform][] implementations *may* implement the `transform._flush()` |
1713 | 1713 | method. This will be called when there is no more written data to be consumed, |
1714 | 1714 | but before the [`'end'`][] event is emitted signaling the end of the |
1715 | 1715 | [Readable][] stream. |
1716 | 1716 |
|
1717 | | -Within the `transform.\_flush()` implementation, the `readable.push()` method |
| 1717 | +Within the `transform._flush()` implementation, the `readable.push()` method |
1718 | 1718 | may be called zero or more times, as appropriate. The `callback` function must |
1719 | 1719 | be called when the flush operation is complete. |
1720 | 1720 |
|
1721 | | -The `transform.\_flush()` method is prefixed with an underscore because it is |
| 1721 | +The `transform._flush()` method is prefixed with an underscore because it is |
1722 | 1722 | internal to the class that defines it, and should never be called directly by |
1723 | 1723 | user programs. |
1724 | 1724 |
|
@@ -1738,7 +1738,7 @@ should be implemented by child classes, and called only by the internal Readable |
1738 | 1738 | class methods only. |
1739 | 1739 |
|
1740 | 1740 | All Transform stream implementations must provide a `_transform()` |
1741 | | -method to accept input and produce output. The `transform.\_transform()` |
| 1741 | +method to accept input and produce output. The `transform._transform()` |
1742 | 1742 | implementation handles the bytes being written, computes an output, then passes |
1743 | 1743 | that output off to the readable portion using the `readable.push()` method. |
1744 | 1744 |
|
@@ -1765,7 +1765,7 @@ transform.prototype._transform = function (data, encoding, callback) { |
1765 | 1765 | }; |
1766 | 1766 | ``` |
1767 | 1767 |
|
1768 | | -The `transform.\_transform()` method is prefixed with an underscore because it |
| 1768 | +The `transform._transform()` method is prefixed with an underscore because it |
1769 | 1769 | is internal to the class that defines it, and should never be called directly by |
1770 | 1770 | user programs. |
1771 | 1771 |
|
@@ -1848,7 +1848,7 @@ net.createServer((socket) => { |
1848 | 1848 |
|
1849 | 1849 | In addition to new Readable streams switching into flowing mode, |
1850 | 1850 | pre-v0.10 style streams can be wrapped in a Readable class using the |
1851 | | -[`readable.wrap()`][] method. |
| 1851 | +[`readable.wrap()`][`stream.wrap()`] method. |
1852 | 1852 |
|
1853 | 1853 |
|
1854 | 1854 | ### `readable.read(0)` |
|