An asynchronous variant of Result, wrapped in a Promise.
Promise
The type of the Success value.
The type of the Failure value.
import { Result } from '@praha/byethrow';const fetchData = async (): Result.ResultAsync<string, Error> => { try { const data = await fetch('...'); return { type: 'Success', value: await data.text() }; } catch (err) { return { type: 'Failure', error: err as Error }; }}; Copy
import { Result } from '@praha/byethrow';const fetchData = async (): Result.ResultAsync<string, Error> => { try { const data = await fetch('...'); return { type: 'Success', value: await data.text() }; } catch (err) { return { type: 'Failure', error: err as Error }; }};
An asynchronous variant of Result, wrapped in a
Promise
.