You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...
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).
@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). 🙃 😀
Enter your suggestions in details:
1. What I expected to happen.
The Learn page Reading files with Node.js ends with:
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."
The text was updated successfully, but these errors were encountered: