util.types.isGeneratorObject(value)
如果值是从内置的生成器函数返回的生成器对象,则返回 true
。
这只会报告 JavaScript 引擎看到的内容;特别是,如果使用了转译工具,则返回值可能与原始源代码不匹配。
function* foo() {}
const generator = foo();
util.types.isGeneratorObject(generator); // 返回 true
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