1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const stream = require('stream'); 6 7const r = new stream.Readable({ 8 read: () => {} 9}); 10 11// readableListening state should start in `false`. 12assert.strictEqual(r._readableState.readableListening, false); 13 14r.on('readable', common.mustCall(() => { 15 // Inside the readable event this state should be true. 16 assert.strictEqual(r._readableState.readableListening, true); 17})); 18 19r.push(Buffer.from('Testing readableListening state')); 20 21const r2 = new stream.Readable({ 22 read: () => {} 23}); 24 25// readableListening state should start in `false`. 26assert.strictEqual(r2._readableState.readableListening, false); 27 28r2.on('data', common.mustCall((chunk) => { 29 // readableListening should be false because we don't have 30 // a `readable` listener 31 assert.strictEqual(r2._readableState.readableListening, false); 32})); 33 34r2.push(Buffer.from('Testing readableListening state')); 35