3 ms·
I find using async await leads to a lot more simpler and understandable code. Moreover, one can stick to the try ... catch semantics. It's also a fewer lines t
by wheresvic1 8y ago
I find using async await leads to a lot more simpler and understandable code. Moreover, one can stick to the try ... catch semantics.
It's also a fewer lines than promises and the then calls with the anon functions.
- messe 8y ago> I find using async await leads to a lot more simpler and understandable code. Moreover, one can stick to the try ... catch semantics. > It's also a fewer lines than promises and the then calls with the anon functions. Promises + call with anon functions is still asynchronous code. I'm wondering why not just use easy-to-reason-about, easy-to-read synchronous code for something like this rather than messing around with async/await.
- wheresvic1 8y agoAh I see now - yes you are right that would be an option since both fs an fs-extra provide sync functions. Depending upon the number of files, the async approach will be faster (to be benchmarked) but you are correct that for 100 files or less on a modern computer at least there is probably no perceptible difference. For me personally, I'm just so used to writing it this way, I didn't even think that it could complicate the tutorial - thanks for pointing it out!