From ab366603dbf28cc980642fdfc61f7c628ab86955 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 1 Sep 2024 11:52:36 +0100 Subject: [PATCH] Small improvement of `promise` iteration error handling --- source/iterable.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/iterable.js b/source/iterable.js index cd8c5e1..f8762cb 100644 --- a/source/iterable.js +++ b/source/iterable.js @@ -48,7 +48,7 @@ export const combineAsyncIterators = async function * (...iterators) { } } } finally { - await Promise.all(iterators.map(iterator => iterator.return?.())); + await Promise.all(iterators.map(iterator => iterator.return())); } }; @@ -56,7 +56,6 @@ const getNext = async iterator => { try { return await iterator.next(); } catch (error) { - await iterator.throw?.(error); - throw error; + await iterator.throw(error); } };