Reflection to know if executed within a generator/async ?

Tab Atkins Jr. jackalmage at
Tue Dec 8 17:38:51 UTC 2015

On Sun, Dec 6, 2015 at 10:48 PM, Andrea Giammarchi
<andrea.giammarchi at> wrote:
> 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.

This pattern is fine; different overloads of a function are basically
different functions, and we're using this pattern in the web platform
in a few places to "update" some CB-using APIs to Promises.  As long
as the function previously returned void and took the CB last, we can
do it.


More information about the es-discuss mailing list