@@ -499,6 +499,15 @@ write('hello', () => {
499
499
500
500
A Writable stream in object mode will always ignore the ` encoding ` argument.
501
501
502
+ ##### writable.destroy([ error] )
503
+ <!-- YAML
504
+ added: REPLACEME
505
+ -->
506
+
507
+ Destroy the stream, and emit the passed error. After this call, the
508
+ writible stream has ended. Implementors should not override this method,
509
+ but instead implement [ ` writable._destroy ` ] [ writable-_destroy ] .
510
+
502
511
### Readable Streams
503
512
504
513
Readable streams are an abstraction for a * source* from which data is
@@ -1070,6 +1079,16 @@ myReader.on('readable', () => {
1070
1079
});
1071
1080
```
1072
1081
1082
+ ##### readable.destroy([ error] )
1083
+ <!-- YAML
1084
+ added: REPLACEME
1085
+ -->
1086
+
1087
+ Destroy the stream, and emit ` 'error' ` . After this call, the
1088
+ readable stream will release any internal resources.
1089
+ Implementors should not override this method, but instead implement
1090
+ [ ` readable._destroy ` ] [ readable-_destroy ] .
1091
+
1073
1092
### Duplex and Transform Streams
1074
1093
1075
1094
#### Class: stream.Duplex
@@ -1109,6 +1128,16 @@ Examples of Transform streams include:
1109
1128
* [ zlib streams] [ zlib ]
1110
1129
* [ crypto streams] [ crypto ]
1111
1130
1131
+ ##### transform.destroy([ error] )
1132
+ <!-- YAML
1133
+ added: REPLACEME
1134
+ -->
1135
+
1136
+ Destroy the stream, and emit ` 'error' ` . After this call, the
1137
+ transform stream would release any internal resources.
1138
+ implementors should not override this method, but instead implement
1139
+ [ ` readable._destroy ` ] [ readable-_destroy ] .
1140
+ The default implementation of ` _destroy ` for ` Transform ` also emit ` 'close' ` .
1112
1141
1113
1142
## API for Stream Implementers
1114
1143
@@ -1247,6 +1276,8 @@ constructor and implement the `writable._write()` method. The
1247
1276
[ ` stream._write() ` ] [ stream-_write ] method.
1248
1277
* ` writev ` {Function} Implementation for the
1249
1278
[ ` stream._writev() ` ] [ stream-_writev ] method.
1279
+ * ` destroy ` {Function} Implementation for the
1280
+ [ ` stream._destroy() ` ] [ writable-_destroy ] method.
1250
1281
1251
1282
For example:
1252
1283
@@ -1356,6 +1387,15 @@ The `writable._writev()` method is prefixed with an underscore because it is
1356
1387
internal to the class that defines it, and should never be called directly by
1357
1388
user programs.
1358
1389
1390
+ #### writable.\_ destroy(err, callback)
1391
+ <!-- YAML
1392
+ added: REPLACEME
1393
+ -->
1394
+
1395
+ * ` err ` {Error} An error.
1396
+ * ` callback ` {Function} A callback function that takes an optional error argument
1397
+ which is invoked when the writable is destroyed.
1398
+
1359
1399
#### Errors While Writing
1360
1400
1361
1401
It is recommended that errors occurring during the processing of the
@@ -1425,6 +1465,8 @@ constructor and implement the `readable._read()` method.
1425
1465
a single value instead of a Buffer of size n. Defaults to ` false `
1426
1466
* ` read ` {Function} Implementation for the [ ` stream._read() ` ] [ stream-_read ]
1427
1467
method.
1468
+ * ` destroy ` {Function} Implementation for the [ ` stream._destroy() ` ] [ readable-_destroy ]
1469
+ method.
1428
1470
1429
1471
For example:
1430
1472
@@ -2073,4 +2115,8 @@ readable buffer so there is nothing for a user to consume.
2073
2115
[ stream-read ] : #stream_readable_read_size
2074
2116
[ stream-resume ] : #stream_readable_resume
2075
2117
[ stream-write ] : #stream_writable_write_chunk_encoding_callback
2076
- [ zlib ] : zlib.html
2118
+ [ readable-_destroy ] : #stream_readable_destroy_err_callback
2119
+ [ writable-_destroy ] : #stream_writable_destroy_err_callback
2120
+ [ TCP sockets ] : net.html#net_class_net_socket
2121
+ [ Transform ] : #stream_class_stream_transform
2122
+ [ Writable ] : #stream_class_stream_writable
0 commit comments