javascript - nodejs Promise.allSettled 的“已完成”和“已拒绝”常量
问题描述
我最近一直在使用Promise.allSettled
并行运行异步方法并收集成功/失败的结果。
我通常会做类似的事情:
const results = await Promise.allSettled([doSomething(), doSomethingElse()]);
const happy = results.filter((result) => result.status === "fulfilled").map((result) => result.value);
const sad = results.filter((result) => result.status === "rejected").map((result) => result.reason);
"fulfilled"
我想知道字符串和是否有任何常量"rejected"
?
解决方案
推荐阅读
- pandas - 数据框列分别包含许多换行符 (\n) 及其值。如何也将其分隔为新列和值
- java - IndexOutOfRangeException (C#) 与 ArrayIndexOutOfBoundsException(Java)
- airflow - 你好Apache Airflow的世界不工作
- kubernetes - 计划作业以在 Kubernetes 中同步外部文件系统上的文件
- python - 在 Pandas 中过滤多个值
- spring-boot - 如何在 Spring Boot RSocket Reactive 中处理入站流取消
- python - 进度条百分比
- prolog - 如何在 Prolog 中获得 not 效果
- javascript - 在我的警报效果代码中添加 twitch 用户名
- ios - 初始化 FlutterFFmpegConfig() 时,Flutter 应用程序在发布模式下崩溃;