-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
why readFileSync and writeFileSync instead of having promises? #266
Comments
We can have those too, but sync file I/O is more often what is needed, and what we'll be implementing first. |
ah ok, that seems reasonable if you think sync i/o is more common. Just wanted to make sure we weren't following a legacy node-ism unnecessarily. Thanks for the clarification. |
When you consider |
@ZanderBrown Yes- the sync methods can call directly into sync syscalls. The awaited async methods go through a thread pool and then polling for completion on the event loop - which ends up being slower in most cases. |
^ ^ ^ ^ ^ This is probably the only lamentable thing I've encountered with async/await. It makes code appear synchronous syntactically but under the hood it's not. |
Looking at the roadmap document, I see the 2 exposed filesystem calls use the node similar syntax of
readFileSync
andwriteFileSync
, but thefetch
call returns a promise. I'm wondering why not just makereadFile
andwriteFile
be promise based and consistently return a promise event for any of these "will complete in the future" API calls?The text was updated successfully, but these errors were encountered: