Reflection to know if executed within a generator/async ?

Claude Pache claude.pache at
Mon Dec 7 07:59:50 UTC 2015

> Le 7 déc. 2015 à 07:48, Andrea Giammarchi <andrea.giammarchi at> a écrit :
> I've asked for opinions and if in 2 days I haven't replied means I got it my idea is not welcome which is OK and fair enough.
> However, I'm curious to know about this "Functions that sometimes return promises and sometimes not are already known to be an antipattern" because I have a library that does that in somehow explicit way (if you pass a callback it doesn't return  a promise, it invokes such callback once resolved) and it works without any real-world problem.
> Mind pointing me at the library that failed returning Promises arbitrarily?

The blog post pointed by Ron earlier in this thread contains a discussion about how sync and async code differ, and thus why it is generally not a good idea to execute random code sometimes asynchronously and sometimes not (with a pointer to a concrete example). It is worth reading.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list