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

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

Open
henrik-jensen opened this issue Jul 12, 2024 · 2 comments

Comments

@henrik-jensen
Copy link

henrik-jensen commented Jul 12, 2024

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."

@ovflowd
Copy link
Member

ovflowd commented Jul 20, 2024

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?

@henrik-jensen
Copy link
Author

henrik-jensen commented Jul 22, 2024

@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). 🙃 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants