@@ -282,11 +282,19 @@ The `finished` API also provides a [callback version][stream-finished].
282282
283283### Object mode
284284
285- All streams created by Node.js APIs operate exclusively on strings and ` Buffer `
286- (or ` Uint8Array ` ) objects. It is possible, however, for stream implementations
287- to work with other types of JavaScript values (with the exception of ` null ` ,
288- which serves a special purpose within streams). Such streams are considered to
289- operate in "object mode".
285+ All streams created by Node.js APIs operate exclusively on strings, {Buffer},
286+ {TypedArray} and {DataView} objects:
287+
288+ * ` Strings ` and ` Buffers ` are the most common types used with streams.
289+ * ` TypedArray ` and ` DataView ` lets you handle binary data with types like
290+ ` Int32Array ` or ` Uint8Array ` . When you write a TypedArray or DataView to a
291+ stream, Node.js processes
292+ the raw bytes.
293+
294+ It is possible, however, for stream
295+ implementations to work with other types of JavaScript values (with the
296+ exception of ` null ` , which serves a special purpose within streams).
297+ Such streams are considered to operate in "object mode".
290298
291299Stream instances are switched into object mode using the ` objectMode ` option
292300when the stream is created. Attempting to switch an existing stream into
@@ -712,6 +720,9 @@ console.log(myStream.destroyed); // true
712720<!-- YAML
713721added: v0.9.4
714722changes:
723+ - version: REPLACEME
724+ pr-url: https://github.com/nodejs/node/pull/51866
725+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
715726 - version: v15.0.0
716727 pr-url: https://github.com/nodejs/node/pull/34101
717728 description: The `callback` is invoked before 'finish' or on error.
@@ -726,10 +737,10 @@ changes:
726737 description: The `chunk` argument can now be a `Uint8Array` instance.
727738-->
728739
729- * ` chunk ` {string|Buffer|Uint8Array| any} Optional data to write. For streams
730- not operating in object mode, ` chunk ` must be a string, ` Buffer ` or
731- ` Uint8Array ` . For object mode streams, ` chunk ` may be any JavaScript value
732- other than ` null ` .
740+ * ` chunk ` {string|Buffer|TypedArray|DataView| any} Optional data to write. For
741+ streams not operating in object mode, ` chunk ` must be a { string}, { Buffer},
742+ {TypedArray} or {DataView} . For object mode streams, ` chunk ` may be any
743+ JavaScript value other than ` null ` .
733744* ` encoding ` {string} The encoding if ` chunk ` is a string
734745* ` callback ` {Function} Callback for when the stream is finished.
735746* Returns: {this}
@@ -926,6 +937,9 @@ Getter for the property `objectMode` of a given `Writable` stream.
926937<!-- YAML
927938added: v0.9.4
928939changes:
940+ - version: REPLACEME
941+ pr-url: https://github.com/nodejs/node/pull/51866
942+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
929943 - version: v8.0.0
930944 pr-url: https://github.com/nodejs/node/pull/11608
931945 description: The `chunk` argument can now be a `Uint8Array` instance.
@@ -935,10 +949,10 @@ changes:
935949 considered invalid now, even in object mode.
936950-->
937951
938- * ` chunk ` {string|Buffer|Uint8Array| any} Optional data to write. For streams
939- not operating in object mode, ` chunk ` must be a string, ` Buffer ` or
940- ` Uint8Array ` . For object mode streams, ` chunk ` may be any JavaScript value
941- other than ` null ` .
952+ * ` chunk ` {string|Buffer|TypedArray|DataView| any} Optional data to write. For
953+ streams not operating in object mode, ` chunk ` must be a { string}, { Buffer},
954+ {TypedArray} or {DataView} . For object mode streams, ` chunk ` may be any
955+ JavaScript value other than ` null ` .
942956* ` encoding ` {string|null} The encoding, if ` chunk ` is a string. ** Default:** ` 'utf8' `
943957* ` callback ` {Function} Callback for when this chunk of data is flushed.
944958* Returns: {boolean} ` false ` if the stream wishes for the calling code to
@@ -1763,15 +1777,18 @@ setTimeout(() => {
17631777<!-- YAML
17641778added: v0.9.11
17651779changes:
1780+ - version: REPLACEME
1781+ pr-url: https://github.com/nodejs/node/pull/51866
1782+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
17661783 - version: v8.0.0
17671784 pr-url: https://github.com/nodejs/node/pull/11608
17681785 description: The `chunk` argument can now be a `Uint8Array` instance.
17691786-->
17701787
1771- * ` chunk ` {Buffer|Uint8Array| string|null|any} Chunk of data to unshift onto the
1772- read queue. For streams not operating in object mode, ` chunk ` must be a
1773- string, ` Buffer ` , ` Uint8Array ` , or ` null ` . For object mode streams, ` chunk `
1774- may be any JavaScript value.
1788+ * ` chunk ` {Buffer|TypedArray|DataView| string|null|any} Chunk of data to unshift
1789+ onto the read queue. For streams not operating in object mode, ` chunk ` must
1790+ be a { string}, { Buffer}, {TypedArray}, {DataView} or ` null ` .
1791+ For object mode streams, ` chunk ` may be any JavaScript value.
17751792* ` encoding ` {string} Encoding of string chunks. Must be a valid
17761793 ` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
17771794
@@ -3525,8 +3542,8 @@ changes:
35253542 ** Default:** ` 'utf8' ` .
35263543 * ` objectMode ` {boolean} Whether or not the
35273544 [ ` stream.write(anyObj) ` ] [ stream-write ] is a valid operation. When set,
3528- it becomes possible to write JavaScript values other than string,
3529- ` Buffer ` or ` Uint8Array ` if supported by the stream implementation.
3545+ it becomes possible to write JavaScript values other than string, {Buffer},
3546+ {TypedArray} or {DataView} if supported by the stream implementation.
35303547 ** Default:** ` false ` .
35313548 * ` emitClose ` {boolean} Whether or not the stream should emit ` 'close' `
35323549 after it has been destroyed. ** Default:** ` true ` .
@@ -4075,22 +4092,25 @@ It can be overridden by child classes but it **must not** be called directly.
40754092
40764093<!-- YAML
40774094changes:
4095+ - version: REPLACEME
4096+ pr-url: https://github.com/nodejs/node/pull/51866
4097+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
40784098 - version: v8.0.0
40794099 pr-url: https://github.com/nodejs/node/pull/11608
40804100 description: The `chunk` argument can now be a `Uint8Array` instance.
40814101-->
40824102
4083- * ` chunk ` {Buffer|Uint8Array| string|null|any} Chunk of data to push into the
4084- read queue. For streams not operating in object mode, ` chunk ` must be a
4085- string, ` Buffer ` or ` Uint8Array ` . For object mode streams, ` chunk ` may be
4086- any JavaScript value.
4103+ * ` chunk ` {Buffer|TypedArray|DataView| string|null|any} Chunk of data to push
4104+ into the read queue. For streams not operating in object mode, ` chunk ` must
4105+ be a { string}, { Buffer}, {TypedArray} or {DataView} . For object mode streams,
4106+ ` chunk ` may be any JavaScript value.
40874107* ` encoding ` {string} Encoding of string chunks. Must be a valid
40884108 ` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
40894109* Returns: {boolean} ` true ` if additional chunks of data may continue to be
40904110 pushed; ` false ` otherwise.
40914111
4092- When ` chunk ` is a ` Buffer ` , ` Uint8Array ` , or ` string ` , the ` chunk ` of data will
4093- be added to the internal queue for users of the stream to consume.
4112+ When ` chunk ` is a { Buffer}, {TypedArray}, {DataView} or { string} , the ` chunk `
4113+ of data will be added to the internal queue for users of the stream to consume.
40944114Passing ` chunk ` as ` null ` signals the end of the stream (EOF), after which no
40954115more data can be written.
40964116
@@ -4765,8 +4785,9 @@ situations within Node.js where this is done, particularly in the
47654785
47664786Use of ` readable.push('') ` is not recommended.
47674787
4768- Pushing a zero-byte string, ` Buffer ` , or ` Uint8Array ` to a stream that is not in
4769- object mode has an interesting side effect. Because it _ is_ a call to
4788+ Pushing a zero-byte {string}, {Buffer}, {TypedArray} or {DataView} to a stream
4789+ that is not in object mode has an interesting side effect.
4790+ Because it _ is_ a call to
47704791[ ` readable.push() ` ] [ stream-push ] , the call will end the reading process.
47714792However, because the argument is an empty string, no data is added to the
47724793readable buffer so there is nothing for a user to consume.
0 commit comments