The answer is super simple and it's actually a question. Let's say we have your last asyncFunction and the stuff works as you propose, without the Promise past.
Which of the function's two return statements should I wait for? The outer one (which returns undefined) out that inner one from callback? Furthermore, what if you had two async calls in there, nested our sequential it's irrelevant. Which one to await then? Add a setTimeout inside. What now? We use promise so that the caller of the async code knows exactly when we resolve the value. We use await to sugar it a bit. I hope that helps highlight the problem a little. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/8c6b5b5e-0eb4-4501-85fe-74d82b9f0550%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
