1'use strict'; 2 3const common = require('../common'); 4const { Readable } = require('stream'); 5const assert = require('assert'); 6 7// This test verifies that a stream could be resumed after 8// removing the readable event in the same tick 9 10check(new Readable({ 11 objectMode: true, 12 highWaterMark: 1, 13 read() { 14 if (!this.first) { 15 this.push('hello'); 16 this.first = true; 17 return; 18 } 19 20 this.push(null); 21 } 22})); 23 24function check(s) { 25 const readableListener = common.mustNotCall(); 26 s.on('readable', readableListener); 27 s.on('end', common.mustCall()); 28 assert.strictEqual(s.removeListener, s.off); 29 s.removeListener('readable', readableListener); 30 s.resume(); 31} 32