Object.prototype.toString()
and Function.prototype.call()
and check if the result is '[object GeneratorFunction]'
.const isGeneratorFunction = val => Object.prototype.toString.call(val) === '[object GeneratorFunction]';
isGeneratorFunction(function() {}); // false
isGeneratorFunction(function*() {}); // true
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️