It's not quite that simple due to variations across different engines, but I've got a module https://www.npmjs.com/package/is-generator-function that covers it.
On Tue, Mar 3, 2015 at 9:07 AM, Damian Senn <[email protected]> wrote: > Hi Gui > > On 03/03/2015 05:41 PM, Guilherme Souza wrote: > >> Hi all, >> >> I was wondering how one could check if a given function is a generator >> function, is a cross-realm way: >> > > I'm detecting this with the following piece of code: > > if ((function*(){}).constructor.name == 'GeneratorFunction')) { > // is generator function > } > > or something like: > > function isGenerator(fn) { > return fn && fn.constructor && fn.constructor.name == > 'GeneratorFunction' > } > > Regards > Damian > > -- > Adfinis SyGroup AG > Damian Senn, Software Engineer > > Keltenstrasse 98 | CH-3018 Bern > Tel. 031 550 31 11 > > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

