Skip to content

readline: add support for asynchronous iteration (tracking feature request) #18603

Closed
@vsemozhetbyt

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.

Metadata

Assignees

No one assigned

    Labels

    promisesIssues and PRs related to ECMAScript promises.readlineIssues and PRs related to the built-in readline module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions