From 387fdcb14a58247a5aada67afb5ab021dbde069b Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Mon, 23 Jan 2023 16:00:55 +0000 Subject: [PATCH] Autosave: 2023-01-23 16:00:55 --- Programming_Languages/Node/Modules/Core/fs.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Programming_Languages/Node/Modules/Core/fs.md b/Programming_Languages/Node/Modules/Core/fs.md index 7437063..b420613 100644 --- a/Programming_Languages/Node/Modules/Core/fs.md +++ b/Programming_Languages/Node/Modules/Core/fs.md @@ -96,9 +96,3 @@ fs.rmSync("/dir", { recursive: true, force: true }); ## Streams See [Handling streams with fs](/Programming_Languages/Node/Streams.md) - -In the examples above of reading from a file, the `fs.readFile()` method waits until the entire file has been read before executing the callback. It's obvious why this might not be ideal in certain cases. If the file is very large you are utilising a lot of memory for a single process. Additionally, the data you need might appear early in the file, in which case, once you find the data you want, there is no need to read to the end of the file. - -This is why the ability to read files and data as streams exists in Node.js. Streams increase memory and time efficiency. As you are not necessarily reading the whole file, - -Streams are more memory efficient since you are not waiting for the whole file to be read before acting. This also means you can start execution quicker.