Skip to content

Commit 54879ab

Browse files
chdhitaloacasas
authored andcommittedMar 20, 2017
doc: fix mistakes in stream doc (object mode)
This patch fixes some trivial documentation mistakes for streams operating in object mode. For `unshift()`, `_write()`, `push()` and `_transform()`, the data type of the `chunk` parameter is extended with `any` and the description is corrected to take into account that streams can operate in object mode. PR-URL: #11807 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 78ca15d commit 54879ab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed
 

‎doc/api/stream.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ setTimeout(() => {
981981
added: v0.9.11
982982
-->
983983

984-
* `chunk` {Buffer|string} Chunk of data to unshift onto the read queue
984+
* `chunk` {Buffer|string|any} Chunk of data to unshift onto the read queue
985985

986986
The `readable.unshift()` method pushes a chunk of data back into the internal
987987
buffer. This is useful in certain situations where a stream is being consumed by
@@ -1295,8 +1295,9 @@ const myWritable = new Writable({
12951295

12961296
#### writable.\_write(chunk, encoding, callback)
12971297

1298-
* `chunk` {Buffer|string} The chunk to be written. Will **always**
1299-
be a buffer unless the `decodeStrings` option was set to `false`.
1298+
* `chunk` {Buffer|string|any} The chunk to be written. Will **always**
1299+
be a buffer unless the `decodeStrings` option was set to `false`
1300+
or the stream is operating in object mode.
13001301
* `encoding` {string} If the chunk is a string, then `encoding` is the
13011302
character encoding of that string. If chunk is a `Buffer`, or if the
13021303
stream is operating in object mode, `encoding` may be ignored.
@@ -1500,13 +1501,13 @@ user programs.
15001501

15011502
#### readable.push(chunk[, encoding])
15021503

1503-
* `chunk` {Buffer|null|string} Chunk of data to push into the read queue
1504+
* `chunk` {Buffer|null|string|any} Chunk of data to push into the read queue
15041505
* `encoding` {string} Encoding of String chunks. Must be a valid
15051506
Buffer encoding, such as `'utf8'` or `'ascii'`
15061507
* Returns {boolean} `true` if additional chunks of data may continued to be
15071508
pushed; `false` otherwise.
15081509

1509-
When `chunk` is a `Buffer` or `string`, the `chunk` of data will be added to the
1510+
When `chunk` is not `null`, the `chunk` of data will be added to the
15101511
internal queue for users of the stream to consume. Passing `chunk` as `null`
15111512
signals the end of the stream (EOF), after which no more data can be written.
15121513

@@ -1873,8 +1874,9 @@ user programs.
18731874

18741875
#### transform.\_transform(chunk, encoding, callback)
18751876

1876-
* `chunk` {Buffer|string} The chunk to be transformed. Will **always**
1877-
be a buffer unless the `decodeStrings` option was set to `false`.
1877+
* `chunk` {Buffer|string|any} The chunk to be transformed. Will **always**
1878+
be a buffer unless the `decodeStrings` option was set to `false`
1879+
or the stream is operating in object mode.
18781880
* `encoding` {string} If the chunk is a string, then this is the
18791881
encoding type. If chunk is a buffer, then this is the special
18801882
value - 'buffer', ignore it in this case.

0 commit comments

Comments
 (0)
Please sign in to comment.