11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst stream = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const r = new stream.Readable({ 91cb0ef41Sopenharmony_ci read: common.mustCall(function() { 101cb0ef41Sopenharmony_ci this.push('content'); 111cb0ef41Sopenharmony_ci this.push(null); 121cb0ef41Sopenharmony_ci }) 131cb0ef41Sopenharmony_ci }); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const t = new stream.Transform({ 161cb0ef41Sopenharmony_ci transform: common.mustCall(function(chunk, encoding, callback) { 171cb0ef41Sopenharmony_ci this.push(chunk); 181cb0ef41Sopenharmony_ci return callback(); 191cb0ef41Sopenharmony_ci }), 201cb0ef41Sopenharmony_ci flush: common.mustCall(function(callback) { 211cb0ef41Sopenharmony_ci return callback(); 221cb0ef41Sopenharmony_ci }) 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci r.pipe(t); 261cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 271cb0ef41Sopenharmony_ci while (true) { 281cb0ef41Sopenharmony_ci const chunk = t.read(); 291cb0ef41Sopenharmony_ci if (!chunk) 301cb0ef41Sopenharmony_ci break; 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 331cb0ef41Sopenharmony_ci } 341cb0ef41Sopenharmony_ci }, 2)); 351cb0ef41Sopenharmony_ci} 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci{ 381cb0ef41Sopenharmony_ci const t = new stream.Transform({ 391cb0ef41Sopenharmony_ci transform: common.mustCall(function(chunk, encoding, callback) { 401cb0ef41Sopenharmony_ci this.push(chunk); 411cb0ef41Sopenharmony_ci return callback(); 421cb0ef41Sopenharmony_ci }), 431cb0ef41Sopenharmony_ci flush: common.mustCall(function(callback) { 441cb0ef41Sopenharmony_ci return callback(); 451cb0ef41Sopenharmony_ci }) 461cb0ef41Sopenharmony_ci }); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci t.end('content'); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 511cb0ef41Sopenharmony_ci while (true) { 521cb0ef41Sopenharmony_ci const chunk = t.read(); 531cb0ef41Sopenharmony_ci if (!chunk) 541cb0ef41Sopenharmony_ci break; 551cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 561cb0ef41Sopenharmony_ci } 571cb0ef41Sopenharmony_ci })); 581cb0ef41Sopenharmony_ci} 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci{ 611cb0ef41Sopenharmony_ci const t = new stream.Transform({ 621cb0ef41Sopenharmony_ci transform: common.mustCall(function(chunk, encoding, callback) { 631cb0ef41Sopenharmony_ci this.push(chunk); 641cb0ef41Sopenharmony_ci return callback(); 651cb0ef41Sopenharmony_ci }), 661cb0ef41Sopenharmony_ci flush: common.mustCall(function(callback) { 671cb0ef41Sopenharmony_ci return callback(); 681cb0ef41Sopenharmony_ci }) 691cb0ef41Sopenharmony_ci }); 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci t.write('content'); 721cb0ef41Sopenharmony_ci t.end(); 731cb0ef41Sopenharmony_ci 741cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 751cb0ef41Sopenharmony_ci while (true) { 761cb0ef41Sopenharmony_ci const chunk = t.read(); 771cb0ef41Sopenharmony_ci if (!chunk) 781cb0ef41Sopenharmony_ci break; 791cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 801cb0ef41Sopenharmony_ci } 811cb0ef41Sopenharmony_ci })); 821cb0ef41Sopenharmony_ci} 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci{ 851cb0ef41Sopenharmony_ci const t = new stream.Readable({ 861cb0ef41Sopenharmony_ci read() { 871cb0ef41Sopenharmony_ci } 881cb0ef41Sopenharmony_ci }); 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 911cb0ef41Sopenharmony_ci while (true) { 921cb0ef41Sopenharmony_ci const chunk = t.read(); 931cb0ef41Sopenharmony_ci if (!chunk) 941cb0ef41Sopenharmony_ci break; 951cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 961cb0ef41Sopenharmony_ci } 971cb0ef41Sopenharmony_ci })); 981cb0ef41Sopenharmony_ci 991cb0ef41Sopenharmony_ci t.push('content'); 1001cb0ef41Sopenharmony_ci t.push(null); 1011cb0ef41Sopenharmony_ci} 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci{ 1041cb0ef41Sopenharmony_ci const t = new stream.Readable({ 1051cb0ef41Sopenharmony_ci read() { 1061cb0ef41Sopenharmony_ci } 1071cb0ef41Sopenharmony_ci }); 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 1101cb0ef41Sopenharmony_ci while (true) { 1111cb0ef41Sopenharmony_ci const chunk = t.read(); 1121cb0ef41Sopenharmony_ci if (!chunk) 1131cb0ef41Sopenharmony_ci break; 1141cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 1151cb0ef41Sopenharmony_ci } 1161cb0ef41Sopenharmony_ci }, 2)); 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci process.nextTick(() => { 1191cb0ef41Sopenharmony_ci t.push('content'); 1201cb0ef41Sopenharmony_ci t.push(null); 1211cb0ef41Sopenharmony_ci }); 1221cb0ef41Sopenharmony_ci} 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ci{ 1251cb0ef41Sopenharmony_ci const t = new stream.Transform({ 1261cb0ef41Sopenharmony_ci transform: common.mustCall(function(chunk, encoding, callback) { 1271cb0ef41Sopenharmony_ci this.push(chunk); 1281cb0ef41Sopenharmony_ci return callback(); 1291cb0ef41Sopenharmony_ci }), 1301cb0ef41Sopenharmony_ci flush: common.mustCall(function(callback) { 1311cb0ef41Sopenharmony_ci return callback(); 1321cb0ef41Sopenharmony_ci }) 1331cb0ef41Sopenharmony_ci }); 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci t.on('readable', common.mustCall(function() { 1361cb0ef41Sopenharmony_ci while (true) { 1371cb0ef41Sopenharmony_ci const chunk = t.read(); 1381cb0ef41Sopenharmony_ci if (!chunk) 1391cb0ef41Sopenharmony_ci break; 1401cb0ef41Sopenharmony_ci assert.strictEqual(chunk.toString(), 'content'); 1411cb0ef41Sopenharmony_ci } 1421cb0ef41Sopenharmony_ci }, 2)); 1431cb0ef41Sopenharmony_ci 1441cb0ef41Sopenharmony_ci t.write('content'); 1451cb0ef41Sopenharmony_ci t.end(); 1461cb0ef41Sopenharmony_ci} 147