DEV Community

Discussion on: An async/await gotcha

Collapse
 
dvddpl profile image
Davide de Paolis

dunno if it can help but David Walsh wrote about something similar few days ago.
It's not really checking against a variable - or more precisely, the result of a function call - but can be useful to decide if await a function or not (instead of adding a then to the result)
checking the constructor.name of a function returns "AsyncFunction" instead of "Function" if that is indeed an async one :-)

Collapse
 
tyrw profile image
Tyler Warnock

That's a nice bit of intel. In our case we wanted to capture both promises and async, as we're still using both. But I'm going to keep this one in my head for sure πŸ˜ƒ