Type Alias: ResultAsync<T, E>
ResultAsync<T
, E
> = Promise
<Result
<T
, E
>>
Defined in: result.ts:92
An asynchronous variant of Result, wrapped in a Promise
.
Type Parameters
T
T
The type of the Success value.
E
E
The type of the Failure value.
Example
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 };
}
};