@@ -1368,9 +1368,16 @@ Examples:
1368
1368
var duplex = new stream.Duplex ({
1369
1369
read : function (n ) {
1370
1370
// sets this._read under the hood
1371
+
1372
+ // push data onto the read queue, passing null
1373
+ // will signal the end of the stream (EOF)
1374
+ this .push (chunk);
1371
1375
},
1372
1376
write : function (chunk , encoding , next ) {
1373
1377
// sets this._write under the hood
1378
+
1379
+ // An optional error can be passed as the first argument
1380
+ next ()
1374
1381
}
1375
1382
});
1376
1383
@@ -1379,9 +1386,16 @@ var duplex = new stream.Duplex({
1379
1386
var duplex = new stream.Duplex ({
1380
1387
read : function (n ) {
1381
1388
// sets this._read under the hood
1389
+
1390
+ // push data onto the read queue, passing null
1391
+ // will signal the end of the stream (EOF)
1392
+ this .push (chunk);
1382
1393
},
1383
1394
writev : function (chunks , next ) {
1384
1395
// sets this._writev under the hood
1396
+
1397
+ // An optional error can be passed as the first argument
1398
+ next ()
1385
1399
}
1386
1400
});
1387
1401
```
@@ -1391,6 +1405,10 @@ var duplex = new stream.Duplex({
1391
1405
var readable = new stream.Readable ({
1392
1406
read : function (n ) {
1393
1407
// sets this._read under the hood
1408
+
1409
+ // push data onto the read queue, passing null
1410
+ // will signal the end of the stream (EOF)
1411
+ this .push (chunk);
1394
1412
}
1395
1413
});
1396
1414
```
@@ -1400,9 +1418,20 @@ var readable = new stream.Readable({
1400
1418
var transform = new stream.Transform ({
1401
1419
transform : function (chunk , encoding , next ) {
1402
1420
// sets this._transform under the hood
1421
+
1422
+ // generate output as many times as needed
1423
+ // this.push(chunk);
1424
+
1425
+ // call when the current chunk is consumed
1426
+ next ();
1403
1427
},
1404
1428
flush : function (done ) {
1405
1429
// sets this._flush under the hood
1430
+
1431
+ // generate output as many times as needed
1432
+ // this.push(chunk);
1433
+
1434
+ done ();
1406
1435
}
1407
1436
});
1408
1437
```
@@ -1412,6 +1441,9 @@ var transform = new stream.Transform({
1412
1441
var writable = new stream.Writable ({
1413
1442
write : function (chunk , encoding , next ) {
1414
1443
// sets this._write under the hood
1444
+
1445
+ // An optional error can be passed as the first argument
1446
+ next ()
1415
1447
}
1416
1448
});
1417
1449
@@ -1420,6 +1452,9 @@ var writable = new stream.Writable({
1420
1452
var writable = new stream.Writable ({
1421
1453
writev : function (chunks , next ) {
1422
1454
// sets this._writev under the hood
1455
+
1456
+ // An optional error can be passed as the first argument
1457
+ next ()
1423
1458
}
1424
1459
});
1425
1460
```
0 commit comments