Skip to content

Provide streams examples in Learn->manipulating-files->"Reading files with Node.js" article #6921

Closed

Description

@henrik-jensen

Enter your suggestions in details:

1. What I expected to happen.

The Learn page Reading files with Node.js ends with:

...
All three of fs.readFile(), fs.readFileSync() and fsPromises.readFile() read
the full content of the file in memory before returning the data.
This means that big files are going to have a major impact on your memory
consumption and speed of execution of the program.
In this case, a better option is to read the file content using streams.

I would have expected a link to a streams example solving the same problem or at least a link to the streams api (and possibly, hopefully not true, a clarification that this is neck-beard territory
Ken_Thompson_and_Dennis_Ritchie--1973
and too advanced for you, my young padawan 😀)

2. Your reason (if possible, images and videos are welcome).

Reading data from unknown and potentially unreliable sources is a common task in computing, so why not give those young padawans a good head start by teaching the recommended techniques?

3. What I plan to do (Optional but better).

Study the Streams API and see if I can come up with a pull request for the docs, but don't get your hopes too high,- I consider myself still a padawan regarding node.js.

3b. What I believe should be updated (at the request of @ovflowd).

Provide a small example in Reading files with Node.js, if possible, that uses the Streams API as hinted in the last sentence of Reading files with Node.js: "...In this case, a better option is to read the file content using streams."

Activity

  1. ovflowd commented on Jul 20, 2024

    @ovflowd
    Member

    I am not sure what this issue is actually talking about, I'm a bit confused 😅

    Could you rephrase what exactly you believe should be updated/removed?

  2. henrik-jensen commented on Jul 22, 2024

    @henrik-jensen
    Author

    @ovflowd
    Sorry for my convoluted way to ask for some examples using the streams API to read files of unknown length instead of using the fs.readFile functions which apparently is not recommended for this purpose (reading files of unknown length). 🙃 😀

  3. moved this from 📋 Backlog to 🔖 Ready in Node.js Websiteon Feb 4, 2025
  4. moved this from 🔖 Ready to 🏗 In progress in Node.js Websiteon Feb 24, 2025
  5. moved this from 🏗 In progress to ✅ Done in Node.js Websiteon Feb 24, 2025
  6. closed this as completedby moving to ✅ Done in Node.js Websiteon Feb 24, 2025
  7. henrik-jensen commented on Feb 24, 2025

    @henrik-jensen
    Author

    @benhalverson and @ovflowd
    Thanks for the doc patches.
    👍

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

    contentIssues/pr concerning contentgood first issueIssues for newcomershelp wantedlearnIssues/pr concerning the learn section

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions