Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vsemozhetbyt opened this issue Jan 27, 2016 · 2 comments
Labels
good first issue Issues that are suitable for first-time contributors. readline Issues and PRs related to the built-in readline module.

Comments

@vsemozhetbyt
Copy link
Contributor

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.

@silverwind silverwind added the readline Issues and PRs related to the built-in readline module. label Jan 27, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Jan 28, 2016

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

@cjihrig cjihrig added the good first issue Issues that are suitable for first-time contributors. label Jan 28, 2016
@vsemozhetbyt
Copy link
Contributor Author

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

rvagg pushed a commit that referenced this issue Jan 28, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: #4916
PR-URL: #4927
Reviewed-By: Colin Ihrig <[email protected]>
rvagg pushed a commit that referenced this issue Feb 8, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: #4916
PR-URL: #4927
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this issue Feb 17, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: #4916
PR-URL: #4927
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this issue Feb 18, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: #4916
PR-URL: #4927
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this issue Mar 2, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: #4916
PR-URL: #4927
Reviewed-By: Colin Ihrig <[email protected]>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
This commit explicitly calls out the end of line sequences
used to generate line events in the readline module.

Fixes: nodejs#4916
PR-URL: nodejs#4927
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

No branches or pull requests

3 participants