[Home] >  Function >  Check if a value is a generator function

Check if a value is a generator function

JavaScript version

const isGeneratorFunction = (v) => Object.prototype.toString.call(v) === '[object GeneratorFunction]';

Examples

isGeneratorFunction(function () {}); // false
isGeneratorFunction(function* () {}); // true