Skip to content

Commit

Permalink
Small improvement of promise iteration error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 1, 2024
1 parent 2d6e08f commit ab36660
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions source/iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ export const combineAsyncIterators = async function * (...iterators) {
}
}
} finally {
await Promise.all(iterators.map(iterator => iterator.return?.()));
await Promise.all(iterators.map(iterator => iterator.return()));
}
};

const getNext = async iterator => {
try {
return await iterator.next();
} catch (error) {
await iterator.throw?.(error);
throw error;
await iterator.throw(error);
}
};

0 comments on commit ab36660

Please sign in to comment.