javascript - NodeJS - 我们应该返回而不是等待以提高性能
问题描述
当考虑到这个 eslint 规则时,看起来应该避免这种代码(即使规则允许它不是“返回等待”时)
async function foo() {
await bar(); // "cost of an extra microtask before resolving the outer Promise"
} // void return
并改为
async function foo() {
return bar(); //This may be confusing because there is no real return value
}
所以问题是——这个“额外的微任务”真的那么重要吗?
显然,在查看 1 个函数时 - 效果可以忽略不计,但如果它在整个代码库中发生很多怎么办?
解决方案
推荐阅读
- swift - 无法从 FIRStorage 下载用户个人资料图片
- c# - 在 IIS 上部署 ASPNet 核心在除根以外的其他 URI 上出现 404 错误
- eclipse - 如何在 Eclipse Kepler 中安装 Flowable 设计器
- lucene - Alfresco:搜索特定元数据字段的字段
- javascript - 如何避免安装和更新 Vue 组件之间的重复
- c# - 如何在应用程序托管在 IIS 上时启动 ac# 方法?
- analytics - Kaa IoT 平台能否提供预测性数字孪生?
- python - 将两个数据帧与其中一个中的倍数合并
- mysql - EJBCA 重新安装问题
- android - 无法解决:com.shuhart.stepview:stepview:1.2.8