1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const { Readable } = require('stream'); 6 7const buf = Buffer.alloc(8192); 8 9const readable = new Readable({ 10 read: common.mustCall(function() { 11 this.push(buf); 12 }, 31) 13}); 14 15let i = 0; 16 17readable.on('readable', common.mustCall(function() { 18 if (i++ === 10) { 19 // We will just terminate now. 20 process.removeAllListeners('readable'); 21 return; 22 } 23 24 const data = readable.read(); 25 // TODO(mcollina): there is something odd in the highWaterMark logic 26 // investigate. 27 if (i === 1) { 28 assert.strictEqual(data.length, 8192 * 2); 29 } else { 30 assert.strictEqual(data.length, 8192 * 3); 31 } 32}, 11)); 33