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