📌  相关文章
📜  检查函数是否为异步 javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:17.395000             🧑  作者: Mango

代码示例1
let promise = fnThatYouWannaCheck();

if(promise && typeof promise.then === 'function' 
   && promise[Symbol.toStringTag] === 'Promise')
{
      // is compliant native promise implementation
}
else
{
      throw new Error('async function expected');
}