ResultMaybeAsync<
T
,E
> =Result
<T
,E
> |Promise
<Result
<T
,E
>>
Defined in: result.ts:116
A result that may be either synchronous or asynchronous.
T
The type of the Success value.
E
The type of the Failure value.
import { import Result
Result } from '@praha/byethrow';
const const result: Result.ResultMaybeAsync<number, string>
result : import Result
Result .type ResultMaybeAsync<T, E> = Result.Result<T, E> | Promise<Result.Result<T, E>>
A result that may be either synchronous or asynchronous.
@typeParamT
- The type of the Success
value.@typeParamE
- The type of the Failure
value.@exampleSynchronous
Case
import { Result } from '@praha/byethrow';
const result: Result.ResultMaybeAsync<number, string> = { type: 'Success', value: 10 };
@exampleAsynchronous
Case
import { Result } from '@praha/byethrow';
const result: Result.ResultMaybeAsync<number, string> = Promise.resolve({ type: 'Failure', error: 'error' });
@categoryCore
Types ResultMaybeAsync <number, string> = { type: "Success"
type : 'Success', value: number
value : 10 };
import { import Result
Result } from '@praha/byethrow';
const const result: Result.ResultMaybeAsync<number, string>
result : import Result
Result .type ResultMaybeAsync<T, E> = Result.Result<T, E> | Promise<Result.Result<T, E>>
A result that may be either synchronous or asynchronous.
@typeParamT
- The type of the Success
value.@typeParamE
- The type of the Failure
value.@exampleSynchronous
Case
import { Result } from '@praha/byethrow';
const result: Result.ResultMaybeAsync<number, string> = { type: 'Success', value: 10 };
@exampleAsynchronous
Case
import { Result } from '@praha/byethrow';
const result: Result.ResultMaybeAsync<number, string> = Promise.resolve({ type: 'Failure', error: 'error' });
@categoryCore
Types ResultMaybeAsync <number, string> = var Promise: PromiseConstructor
Represents the completion of an asynchronous operation
Promise .PromiseConstructor.resolve<{
type: "Failure";
error: string;
}>(value: {
type: "Failure";
error: string;
}): Promise<{
type: "Failure";
error: string;
}> (+2 overloads)
Creates a new resolved promise for the provided value.
@paramvalue
A promise.@returnsA
promise whose internal state matches the provided promise. resolve ({ type: "Failure"
type : 'Failure', error: string
error : 'error' });