Skip to content

Possible improvement of "Read file stream line-by-line" example in readline doc  #5842

Closed

Description

@vsemozhetbyt

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

Would it be for more efficiency, speed, resource saving and consistency to update this call:

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

with these options:

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

Activity

  1. added
    question
    fs
    readline
    on Mar 22, 2016
  2. added
    doc
    question
    and removed
    fs
    question
    on Mar 22, 2016
  3. justsml commented on Mar 25, 2016

    @justsml

    I'm not sure about the terminal: false
    The option has awareness based on output stream, and in your example, no output stream will cause it to be false (I may be mistaken, but that's how i've coded with it).

    Btw, I can barely measure the overhead of historySize... So I'm not sure on that.


    A related side note:

    The Tiny CLI example is useful for one use case. But I was thinking of adding a another example - say, a short (<30 line) CSV parser to handle line breaks in rows...
    I don't know if that's really useful to enough ppl though?
    Any thoughts @Fishrock123 @mscdex ?

    Thanks!

  4. vsemozhetbyt commented on Apr 22, 2016

    @vsemozhetbyt
    ContributorAuthor

    May be will be dealt with in the #6352

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

    docquestionreadline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions