Checks if the given value is a Generator Function (opens in a new tab).
Syntax
import { isGenFn } from '@opentf/std';
isGenFn(
val: unknown
): boolean
Examples
isGenFn(function() {}) //=> false
isGenFn({}) //=> false
function* generator(i) {
yield i;
yield i + 10;
}
isGenFn(generator); //=> true
async function* aGen(i) {
yield i;
yield i + 10;
}
isGenFn(aGen); //=> true
const someObj = {
*generator() {
yield "a";
yield "b";
},
};
isGenFn(someObj.generator); //=> true