UNPKG

return-style

Version:

Non-intrusively convert the result of any function or promise to the user's desired style.

15 lines (13 loc) 299 B
import { pass } from '@blackglory/prelude' export async function getErrorAsyncIterable<E = Error>( iterable: AsyncIterable<unknown> ): Promise<E | undefined> { try { for await (const _ of iterable) { pass() } } catch (promiseError: any) { return promiseError } return }