Skip to content

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

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.

Activity

  1. added
    readlineIssues and PRs related to the built-in readline module.
    on Jan 27, 2016
  2. cjihrig commented on Jan 28, 2016

    @cjihrig
    Contributor

    Looking at the code, it looks like it does check for all three cases. Care to make a docs PR?

  3. vsemozhetbyt commented on Jan 28, 2016

    @vsemozhetbyt
    ContributorAuthor

    Sorry, my English and Github skills are not that good.

  4. added a commit that references this issue on Jan 28, 2016
  5. added a commit that references this issue on Feb 8, 2016
  6. added a commit that references this issue on Apr 2, 2016
  7. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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