4 ms·
That would seem to make sense, using readFileSync() instead. I assume it would really do much the same thing as the await example. Is there any difference? If
by galaxyLogic 7y ago
That would seem to make sense, using readFileSync() instead.
I assume it would really do much the same thing as the await example. Is there any difference?
If they do the same thing, then what's the benefit of async/await? I guess it's that you can now write your own "fs.readFileSync()" or something like that in JavaScript when needed.
- jeswin 7y agofs.readFileSync() blocks the event loop preventing any other code from being run or other events/requests from being processed. Await yields control back so that other requests can be processed while the file is being read.
- galaxyLogic 7y agoAh I see. Genius. So is there ever a use-case for NOT using the Async/Await -version of readFile()? Is fsReadSync() now just legacy which we don't need any more?