Provide streams examples in Learn->manipulating-files->"Reading files with Node.js" article
henrik-jensen opened this issue · comments
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
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."
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?
@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). 🙃 😀