3 ms·
One more thing that's particularly nice about `async/await` is just using the `async` part. For existing functions that should always return promises, when that
by rictic 10y ago
One more thing that's particularly nice about `async/await` is just using the `async` part. For existing functions that should always return promises, when that function is `async` you can be sure of it. Even if it throws. Even if it returns a value that sometimes isn't a promise.
Makes writing correct code easier.
- breatheoften 10y agoI'm not up to speed on async/await -- do you happen to know if an async function throws on synchronous code (before the first await keyword) -- does that result in an asynchronously rejected promise or a synchronous exception?
- deleted 10y ago[deleted]
- minitech 10y agoIt results in a rejected promise. (The other behaviour would be a bit inconsistent/annoying.)
- cletusw 10y agoThis added contract between the caller and callee is huge. No more searching for that one branch of a non-trivial function that failed to wrap its immediately available return value in a Promise.