I expect the code below to create a Readline Interface with a readable stream from a file with a list of ~1000 URLs, start streaming from the input stream (logging a line to the console), and then pause:
var readline = require('readline');
var fs = require('fs');
var rlinterface = readline.createInterface({
input: fs.createReadStream('urls.txt'),
output: null,
terminal: false
});
rlinterface.on('pause', function() {
console.log('Readline paused.');
});
rlinterface.on('line', function(line){
console.log(line);
rlinterface.pause();
});
The listener for the pause
event notifies me that the stream should be paused, but all of the lines in the file from the input stream are logged to the console, suggesting that the stream never paused. Even if the stream doesn't pause immediately after the first line (maybe a few extra lines need to be captured in a buffer), I don't expect all of the lines from the file from the input stream to be streamed before the 'pause'. So what's going on?