@@ -283,10 +283,10 @@ The `finished` API also provides a [callback version][stream-finished].
283
283
### Object mode
284
284
285
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".
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".
290
290
291
291
Stream instances are switched into object mode using the ` objectMode ` option
292
292
when the stream is created. Attempting to switch an existing stream into
@@ -712,6 +712,9 @@ console.log(myStream.destroyed); // true
712
712
<!-- YAML
713
713
added: v0.9.4
714
714
changes:
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.
715
718
- version: v15.0.0
716
719
pr-url: https://github.com/nodejs/node/pull/34101
717
720
description: The `callback` is invoked before 'finish' or on error.
@@ -726,10 +729,10 @@ changes:
726
729
description: The `chunk` argument can now be a `Uint8Array` instance.
727
730
-->
728
731
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 ` .
733
736
* ` encoding ` {string} The encoding if ` chunk ` is a string
734
737
* ` callback ` {Function} Callback for when the stream is finished.
735
738
* Returns: {this}
@@ -926,6 +929,9 @@ Getter for the property `objectMode` of a given `Writable` stream.
926
929
<!-- YAML
927
930
added: v0.9.4
928
931
changes:
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.
929
935
- version: v8.0.0
930
936
pr-url: https://github.com/nodejs/node/pull/11608
931
937
description: The `chunk` argument can now be a `Uint8Array` instance.
@@ -935,10 +941,10 @@ changes:
935
941
considered invalid now, even in object mode.
936
942
-->
937
943
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 ` .
942
948
* ` encoding ` {string|null} The encoding, if ` chunk ` is a string. ** Default:** ` 'utf8' `
943
949
* ` callback ` {Function} Callback for when this chunk of data is flushed.
944
950
* Returns: {boolean} ` false ` if the stream wishes for the calling code to
@@ -1763,15 +1769,18 @@ setTimeout(() => {
1763
1769
<!-- YAML
1764
1770
added: v0.9.11
1765
1771
changes:
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.
1766
1775
- version: v8.0.0
1767
1776
pr-url: https://github.com/nodejs/node/pull/11608
1768
1777
description: The `chunk` argument can now be a `Uint8Array` instance.
1769
1778
-->
1770
1779
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.
1775
1784
* ` encoding ` {string} Encoding of string chunks. Must be a valid
1776
1785
` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
1777
1786
@@ -3512,8 +3521,8 @@ changes:
3512
3521
** Default:** ` 'utf8' ` .
3513
3522
* ` objectMode ` {boolean} Whether or not the
3514
3523
[ ` 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.
3517
3526
** Default:** ` false ` .
3518
3527
* ` emitClose ` {boolean} Whether or not the stream should emit ` 'close' `
3519
3528
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.
4062
4071
4063
4072
<!-- YAML
4064
4073
changes:
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.
4065
4077
- version: v8.0.0
4066
4078
pr-url: https://github.com/nodejs/node/pull/11608
4067
4079
description: The `chunk` argument can now be a `Uint8Array` instance.
4068
4080
-->
4069
4081
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.
4074
4086
* ` encoding ` {string} Encoding of string chunks. Must be a valid
4075
4087
` Buffer ` encoding, such as ` 'utf8' ` or ` 'ascii' ` .
4076
4088
* Returns: {boolean} ` true ` if additional chunks of data may continue to be
4077
4089
pushed; ` false ` otherwise.
4078
4090
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.
4081
4093
Passing ` chunk ` as ` null ` signals the end of the stream (EOF), after which no
4082
4094
more data can be written.
4083
4095
@@ -4752,8 +4764,9 @@ situations within Node.js where this is done, particularly in the
4752
4764
4753
4765
Use of ` readable.push('') ` is not recommended.
4754
4766
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
4757
4770
[ ` readable.push() ` ] [ stream-push ] , the call will end the reading process.
4758
4771
However, because the argument is an empty string, no data is added to the
4759
4772
readable buffer so there is nothing for a user to consume.
0 commit comments