@@ -283,10 +283,10 @@ The `finished` API also provides a [callback version][stream-finished].
283283### Object mode
284284
285285All 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".
286+ (or {TypedArray} and {DataView} ) objects. It is possible, however, for stream
287+ implementations to work with other types of JavaScript values (with the
288+ exception of ` null ` , which serves a special purpose within streams).
289+ Such streams are considered to operate in "object mode".
290290
291291Stream instances are switched into object mode using the ` objectMode ` option
292292when the stream is created. Attempting to switch an existing stream into
@@ -712,6 +712,9 @@ console.log(myStream.destroyed); // true
712712<!-- YAML
713713added: v0.9.4
714714changes:
715+ - version: REPLACEME
716+ pr-url: https://github.com/nodejs/node/pull/51866
717+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
715718 - version: v15.0.0
716719 pr-url: https://github.com/nodejs/node/pull/34101
717720 description: The `callback` is invoked before 'finish' or on error.
@@ -726,10 +729,10 @@ changes:
726729 description: The `chunk` argument can now be a `Uint8Array` instance.
727730-->
728731
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 ` .
732+ * ` chunk ` {string|Buffer|TypedArray|DataView| any} Optional data to write. For
733+ streams not operating in object mode, ` chunk ` must be a { string}, { Buffer},
734+ {TypedArray} or {DataView} . For object mode streams, ` chunk ` may be any
735+ JavaScript value other than ` null ` .
733736* ` encoding ` {string} The encoding if ` chunk ` is a string
734737* ` callback ` {Function} Callback for when the stream is finished.
735738* Returns: {this}
@@ -926,6 +929,9 @@ Getter for the property `objectMode` of a given `Writable` stream.
926929<!-- YAML
927930added: v0.9.4
928931changes:
932+ - version: REPLACEME
933+ pr-url: https://github.com/nodejs/node/pull/51866
934+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
929935 - version: v8.0.0
930936 pr-url: https://github.com/nodejs/node/pull/11608
931937 description: The `chunk` argument can now be a `Uint8Array` instance.
@@ -935,10 +941,10 @@ changes:
935941 considered invalid now, even in object mode.
936942-->
937943
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 ` .
944+ * ` chunk ` {string|Buffer|TypedArray|DataView| any} Optional data to write. For
945+ streams not operating in object mode, ` chunk ` must be a { string}, { Buffer},
946+ {TypedArray} or {DataView} . For object mode streams, ` chunk ` may be any
947+ JavaScript value other than ` null ` .
942948* ` encoding ` {string|null} The encoding, if ` chunk ` is a string. ** Default:** ` 'utf8' `
943949* ` callback ` {Function} Callback for when this chunk of data is flushed.
944950* Returns: {boolean} ` false ` if the stream wishes for the calling code to
@@ -1763,15 +1769,18 @@ setTimeout(() => {
17631769<!-- YAML
17641770added: v0.9.11
17651771changes:
1772+ - version: REPLACEME
1773+ pr-url: https://github.com/nodejs/node/pull/51866
1774+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
17661775 - version: v8.0.0
17671776 pr-url: https://github.com/nodejs/node/pull/11608
17681777 description: The `chunk` argument can now be a `Uint8Array` instance.
17691778-->
17701779
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.
1780+ * ` chunk ` {Buffer|TypedArray|DataView| string|null|any} Chunk of data to unshift
1781+ onto the read queue. For streams not operating in object mode, ` chunk ` must
1782+ be a { string}, { Buffer}, {TypedArray}, {DataView} or ` null ` .
1783+ For object mode streams, ` chunk ` may be any JavaScript value.
17751784* ` encoding ` {string} Encoding of string chunks. Must be a valid
17761785 ` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
17771786
@@ -3512,8 +3521,8 @@ changes:
35123521 ** Default:** ` 'utf8' ` .
35133522 * ` objectMode ` {boolean} Whether or not the
35143523 [ ` stream.write(anyObj) ` ] [ stream-write ] is a valid operation. When set,
3515- it becomes possible to write JavaScript values other than string,
3516- ` Buffer ` or ` Uint8Array ` if supported by the stream implementation.
3524+ it becomes possible to write JavaScript values other than string, {Buffer},
3525+ {TypedArray} or {DataView} if supported by the stream implementation.
35173526 ** Default:** ` false ` .
35183527 * ` emitClose ` {boolean} Whether or not the stream should emit ` 'close' `
35193528 after it has been destroyed. ** Default:** ` true ` .
@@ -4062,22 +4071,25 @@ It can be overridden by child classes but it **must not** be called directly.
40624071
40634072<!-- YAML
40644073changes:
4074+ - version: REPLACEME
4075+ pr-url: https://github.com/nodejs/node/pull/51866
4076+ description: The `chunk` argument can now be a `TypedArray` or `DataView` instance.
40654077 - version: v8.0.0
40664078 pr-url: https://github.com/nodejs/node/pull/11608
40674079 description: The `chunk` argument can now be a `Uint8Array` instance.
40684080-->
40694081
4070- * ` chunk ` {Buffer|Uint8Array| string|null|any} Chunk of data to push into the
4071- read queue. For streams not operating in object mode, ` chunk ` must be a
4072- string, ` Buffer ` or ` Uint8Array ` . For object mode streams, ` chunk ` may be
4073- any JavaScript value.
4082+ * ` chunk ` {Buffer|TypedArray|DataView| string|null|any} Chunk of data to push
4083+ into the read queue. For streams not operating in object mode, ` chunk ` must
4084+ be a { string}, { Buffer}, {TypedArray} or {DataView} . For object mode streams,
4085+ ` chunk ` may be any JavaScript value.
40744086* ` encoding ` {string} Encoding of string chunks. Must be a valid
40754087 ` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
40764088* Returns: {boolean} ` true ` if additional chunks of data may continue to be
40774089 pushed; ` false ` otherwise.
40784090
4079- When ` chunk ` is a ` Buffer ` , ` Uint8Array ` , or ` string ` , the ` chunk ` of data will
4080- be added to the internal queue for users of the stream to consume.
4091+ When ` chunk ` is a { Buffer}, {TypedArray}, {DataView} or { string} , the ` chunk `
4092+ of data will be added to the internal queue for users of the stream to consume.
40814093Passing ` chunk ` as ` null ` signals the end of the stream (EOF), after which no
40824094more data can be written.
40834095
@@ -4752,8 +4764,9 @@ situations within Node.js where this is done, particularly in the
47524764
47534765Use of ` readable.push('') ` is not recommended.
47544766
4755- Pushing a zero-byte string, ` Buffer ` , or ` Uint8Array ` to a stream that is not in
4756- object mode has an interesting side effect. Because it _ is_ a call to
4767+ Pushing a zero-byte {string}, {Buffer}, {TypedArray} or {DataView} to a stream
4768+ that is not in object mode has an interesting side effect.
4769+ Because it _ is_ a call to
47574770[ ` readable.push() ` ] [ stream-push ] , the call will end the reading process.
47584771However, because the argument is an empty string, no data is added to the
47594772readable buffer so there is nothing for a user to consume.
0 commit comments