Skip to content
New issue

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

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

Already on GitHub? # to your account

docs: Add usage example of readline line-by-line parsing #4610

Closed
eljefedelrodeodeljefe opened this issue Jan 10, 2016 · 1 comment
Closed
Labels
doc Issues and PRs related to the documentations. readline Issues and PRs related to the built-in readline module.

Comments

@eljefedelrodeodeljefe
Copy link
Contributor

While authoring a parser, I came across what you would normally get in organic search and found lots of it a little dangerous. Namely the use of big module APIs from npm don't occur to make the biggest sense here, since readline has a lot of good functionality built-in. Namely consuming file through readline's interface as steam.

In order to promote use of this, I'd suggest to add an example usage to the docs, which I derived from this stackoverflow link.

This case seemed really common to me, which is why I authored the below PR.

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

const rl = readline.createInterface({
  input: fs.createReadStream('sample.txt')
});

rl.on('line', function (line) {
  console.log('Line from file:', line);
});

PR: #4609

@mscdex mscdex added doc Issues and PRs related to the documentations. readline Issues and PRs related to the built-in readline module. labels Jan 10, 2016
@silverwind
Copy link
Contributor

Oh, this landed in 5a53cba!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
doc Issues and PRs related to the documentations. readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

No branches or pull requests

3 participants