2 ms·
I see your point. What I would do on JS is ... ... on the lib. side, code a single function that behaves the same when meant to run sync or async. ... on the
by moralestapia 2y ago
I see your point.
What I would do on JS is ...
... on the lib. side, code a single function that behaves the same when meant to run sync or async.
... on the client side, just await the function every time is called; if the sync version is running you don't return a Promise and await-ing on primitives is free, the program will lock automatically if needed.
Obviously, the trivial solution would be two different methods that do the same thing (as is the case now with things like readFile and readFileSync) but I agree that's not elegant.