readline: add support for asynchronous iteration (tracking feature request) #18603
Closed
Description
An issue to not forget.
It would be handy to sync readline API with for-await
support in readable streams, so we can do something like this (compare examples here and here):
'use strict';
const readline = require('readline');
const fs = require('fs');
async function processLineByLine(filePath) {
const rli = readline.createInterface({
input: fs.createReadStream(filePath),
crlfDelay: Infinity
});
for await (const line of rli) {
console.log(line);
}
}
processLineByLine('config.ini').catch(console.error);
An evidence of need: "Alas" from Axel Rauschmayer.
An association: Perl <FILEHANDLE>
operator.