From cbe1558993c7ddd8f8c85e3859f6430b4dc39d39 Mon Sep 17 00:00:00 2001 From: Junho Yeo Date: Wed, 12 Oct 2022 17:10:03 +0900 Subject: [PATCH] Revert "[web] Use `reduce` in `safePromiseAll` to make it work for 2D arrays (#309)" This reverts commit 0b93db7fad686ba9bdb69bd081c7d948b997aa8b. --- packages/bento-common/utils/safer-promises.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/bento-common/utils/safer-promises.ts b/packages/bento-common/utils/safer-promises.ts index f11e49f4..25630afe 100644 --- a/packages/bento-common/utils/safer-promises.ts +++ b/packages/bento-common/utils/safer-promises.ts @@ -1,7 +1,6 @@ export const safePromiseAll = async (promises: Promise[]) => - (await Promise.allSettled(promises)).reduce( - (acc, res) => (res.status === 'fulfilled' ? [...acc, res.value] : acc), - [] as T[], + (await Promise.allSettled(promises)).flatMap((res) => + res.status === 'fulfilled' ? res.value : [], ); export const safeAsyncFlatMap = async (