I played with generators in Nodejs v0.11.2 and I\'m wondering how I can check that argument to my function is generator function.
I found this way typeof f ===
A difficulty not addressed on here yet is that if you use the bind
method on the generator function, it changes the name its prototype from 'GeneratorFunction' to 'Function'.
There's no neutral Reflect.bind
method, but you can get around this by resetting the prototype of the bound operation to that of the original operation.
For example:
const boundOperation = operation.bind(someContext, ...args)
console.log(boundOperation.constructor.name) // Function
Reflect.setPrototypeOf(boundOperation, operation)
console.log(boundOperation.constructor.name) // GeneratorFunction