@@ -718,7 +718,7 @@ of stream class you are writing:
718
718
<p>[Writable](#stream_class_stream_writable_1)</p>
719
719
</td>
720
720
<td>
721
- <p><code>[_write][]</code></p>
721
+ <p><code>[_write][]</code>, <code>_writev</code> </p>
722
722
</td>
723
723
</tr >
724
724
<tr >
@@ -729,7 +729,7 @@ of stream class you are writing:
729
729
<p>[Duplex](#stream_class_stream_duplex_1)</p>
730
730
</td>
731
731
<td>
732
- <p><code>[_read][]</code>, <code>[_write][]</code></p>
732
+ <p><code>[_read][]</code>, <code>[_write][]</code>, <code>_writev</code> </p>
733
733
</td>
734
734
</tr >
735
735
<tr >
@@ -1315,6 +1315,77 @@ for examples and testing, but there are occasionally use cases where
1315
1315
it can come in handy as a building block for novel sorts of streams.
1316
1316
1317
1317
1318
+ ## Simplified Constructor API
1319
+
1320
+ <!-- type=misc-->
1321
+
1322
+ In simple cases there is now the added benefit of being able to construct a stream without inheritance.
1323
+
1324
+ This can be done by passing the appropriate methods as constructor options:
1325
+
1326
+ Examples:
1327
+
1328
+ ### Readable
1329
+ ``` javascript
1330
+ var readable = new stream.Readable ({
1331
+ read : function (n ) {
1332
+ // sets this._read under the hood
1333
+ }
1334
+ });
1335
+ ```
1336
+
1337
+ ### Writable
1338
+ ``` javascript
1339
+ var writable = new stream.Writable ({
1340
+ write : function (chunk , encoding , next ) {
1341
+ // sets this._write under the hood
1342
+ }
1343
+ });
1344
+
1345
+ // or
1346
+
1347
+ var writable = new stream.Writable ({
1348
+ writev : function (chunks , next ) {
1349
+ // sets this._writev under the hood
1350
+ }
1351
+ });
1352
+ ```
1353
+
1354
+ ### Duplex
1355
+ ``` javascript
1356
+ var duplex = new stream.Duplex ({
1357
+ read : function (n ) {
1358
+ // sets this._read under the hood
1359
+ },
1360
+ write : function (chunk , encoding , next ) {
1361
+ // sets this._write under the hood
1362
+ }
1363
+ });
1364
+
1365
+ // or
1366
+
1367
+ var duplex = new stream.Duplex ({
1368
+ read : function (n ) {
1369
+ // sets this._read under the hood
1370
+ },
1371
+ writev : function (chunks , next ) {
1372
+ // sets this._writev under the hood
1373
+ }
1374
+ });
1375
+ ```
1376
+
1377
+ ### Transform
1378
+ ``` javascript
1379
+ var transform = new stream.Transform ({
1380
+ transform : function (chunk , encoding , next ) {
1381
+ // sets this._transform under the hood
1382
+ },
1383
+ flush : function (done ) {
1384
+ // sets this._flush under the hood
1385
+ }
1386
+ });
1387
+ ```
1388
+
1318
1389
## Streams: Under the Hood
1319
1390
1320
1391
<!-- type=misc-->
0 commit comments