util.types.isGeneratorObject(value)
如果值是由内置生成器函数返回的生成器对象,则返回 true。
这只会报告 JavaScript 引擎所看到的情况;
特别是,如果使用了转译工具,返回值可能与原始源代码不匹配。
【Returns true if the value is a generator object as returned from a
built-in generator function.
This only reports back what the JavaScript engine is seeing;
in particular, the return value may not match the original source code if
a transpilation tool was used.】
function* foo() {}
const generator = foo();
util.types.isGeneratorObject(generator); // Returns true