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
{{ message }}
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
I think there is a level of inconstancy in the current API with regards to the use of async/sync. In some places, async and sync version of functions are separate with async being default, in other places sync is default, in other async/sync can be implicitly implied depending on whether a callback is supplied.
Firstly, an overview of the current state:
crypto: All implicitly synchronous except pbkdf which is async by default but offers an explicit *Sync() version and randomBytes() where sync/async is implied depending on if a callback is supplied
fs: All implicitly async with explicit sync versions via corresponding *Sync() methods
zlib: Now, implicitly async/sync depending on if callback is supplied
Other modules, such as dns, http, net, os, path etc. are all implicitly sync or async and either do or do not accept a callback.
This was briefly brought up in #6987 and subsequently #7028 but I would like to nail this once and for all across all API's and have a definitive convention if possible?
Personally, I am in favour of depreciating all the explicit *Sync() functions and converging on a convention of async/sync being implicitly implied based on if a callback is supplied. Users would know if a function has async/sync versions based on if a callback is or isn't used respectively. Also, if a callback is not an option, it's always sync. Conversely, if it is required, it's always async with no sync option.
This would be relatively easily integrate into current fs module and would a solid convention moving forward?