util.types.isAsyncFunction(value)


如果值是异步函数,则返回 true。 这只会报告 JavaScript 引擎看到的内容;特别是,如果使用了转译工具,则返回值可能与原始源代码不匹配。

util.types.isAsyncFunction(function foo() {});  // 返回 false
util.types.isAsyncFunction(async function foo() {});  // 返回 true

Returns true if the value is an async 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.

util.types.isAsyncFunction(function foo() {});  // Returns false
util.types.isAsyncFunction(async function foo() {});  // Returns true