11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { Readable, Writable } = require('stream'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Pipe should pause temporarily if writable needs drain. 81cb0ef41Sopenharmony_ci{ 91cb0ef41Sopenharmony_ci const w = new Writable({ 101cb0ef41Sopenharmony_ci write(buf, encoding, callback) { 111cb0ef41Sopenharmony_ci process.nextTick(callback); 121cb0ef41Sopenharmony_ci }, 131cb0ef41Sopenharmony_ci highWaterMark: 1 141cb0ef41Sopenharmony_ci }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci while (w.write('asd')); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci assert.strictEqual(w.writableNeedDrain, true); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci const r = new Readable({ 211cb0ef41Sopenharmony_ci read() { 221cb0ef41Sopenharmony_ci this.push('asd'); 231cb0ef41Sopenharmony_ci this.push(null); 241cb0ef41Sopenharmony_ci } 251cb0ef41Sopenharmony_ci }); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci r.on('pause', common.mustCall(2)); 281cb0ef41Sopenharmony_ci r.on('end', common.mustCall()); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci r.pipe(w); 311cb0ef41Sopenharmony_ci} 32