1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const { Readable, Writable } = require('stream'); 6 7// Pipe should pause temporarily if writable needs drain. 8{ 9 const w = new Writable({ 10 write(buf, encoding, callback) { 11 process.nextTick(callback); 12 }, 13 highWaterMark: 1 14 }); 15 16 while (w.write('asd')); 17 18 assert.strictEqual(w.writableNeedDrain, true); 19 20 const r = new Readable({ 21 read() { 22 this.push('asd'); 23 this.push(null); 24 } 25 }); 26 27 r.on('pause', common.mustCall(2)); 28 r.on('end', common.mustCall()); 29 30 r.pipe(w); 31} 32