Skip to content

readline documentation: event 'line' section wrongly restricts EOL to '\n' only #4916

@vsemozhetbyt

Description

@vsemozhetbyt

https://nodejs.org/api/readline.html#readline_event_line

Emitted whenever the input stream receives a \n, usually received when the user hits enter, or return.

I have tested this code with Windows 7 and Node 5.5.0 on three input files with Win-like EOL (\r\n), *nix-like EOL (\n) and old-Mac-like EOL (\r), and all the outputs were the same.

const fs = require('fs');
const readline = require('readline');

const rl = readline.createInterface({
  input: fs.createReadStream('test.txt', {encoding: 'utf8'}),
  terminal: false,
  historySize: 0
});

rl.on('line', line => {
  console.log(JSON.stringify(line));
});

It seems readline correctly parses files with all the main EOLs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.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