node-argon2
node-argon2 copied to clipboard
Feat request: synchronous version
Why not having a synchronous version of the functions to hash and verify? Bcrypt for example has it and in some niche cases it could be helpful.
What's the niche use case you have in mind?
Something like this https://stackoverflow.com/a/64200074
Also I don't see why someone couldn't be able to choose a synchronous function
Also I don't see why someone couldn't be able to choose a synchronous function
It's a matter of maintaining extra code in order to support a scenario that hasn't really happened in the past years. Even the native Node modules now have a promises version (i.e. fs/promises and readline/promises)
You can use deasync if you really want use synchronous calls, though I highly recommend against
I don't see a relation between the promises version of fs and having a synchronous version for this library.
The promises thing has been introduced because otherwise it would have worked with the ugly old-style callbacks and one would have had to create promises to be able to use async/await Actually the fact that there are sync. versions for most of the functions (such as readdirSync) and the fact that exists has been deprecated in favour of existsSync would suggest the opposite.
Still, I understand if you don't want to have more code to maintain
Yup, that is the major issue. Maintaining a single path has helped keep the library short and simple. It has been requested sporadically in the past #136 #254 #267 and 2 out of 3 times it was lack of information about promises
In the case that it was actually a limitation, I suggested deasync, which ends up being a good solution as you'll likely have to handle other async dependencies in your code. So I consider it a win-win 😉
the fact that exists has been deprecated in favour of existsSync would suggest the opposite
That's not the case though. It has been superseded by stat or access and the removal has more to do with the fact there is a race condition when checking if a file exists prior to operating with it, so it's better to just try the operation and catch the error