logo
byethrow
Guide
Examples
API Reference
Guide
Examples
API Reference
logo
byethrow
@praha/byethrow

Modules

Result

Types

Type Alias: Failure<E>
Type Alias: InferFailure<T>
Type Alias: InferSuccess<T>
Type Alias: Result<T, E>
Type Alias: ResultAsync<T, E>
Type Alias: ResultFor<R, T, E>
Type Alias: ResultMaybeAsync<T, E>
Type Alias: Success<T>

Functions

Function: andThen()
Function: andThrough()
Function: assertFailure()
Function: assertSuccess()
Function: bind()
Function: combine()
Function: do()
Function: fail()
Function: inspect()
Function: inspectError()
Function: isFailure()
Function: isResult()
Function: isSuccess()
Function: map()
Function: mapError()
Function: orElse()
Function: parse()
Function: pipe()
Function: succeed()
Function: try()
Function: unwrap()
Function: unwrapError()

Last Updated:

Previous PageType Alias: ResultFor<R, T, E>
Next PageType Alias: Success<T>

#Type Alias: ResultMaybeAsync<T, E>

ResultMaybeAsync<T, E> = Result<T, E> | Promise<Result<T, E>>

Defined in: result.ts:116

A result that may be either synchronous or asynchronous.

#Type Parameters

#T

T

The type of the Success value.

#E

E

The type of the Failure value.

#Examples

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.@example

Synchronous Case

import { Result } from '@praha/byethrow';

const result: Result.ResultMaybeAsync<number, string> = { type: 'Success', value: 10 };
@example

Asynchronous 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.@example

Synchronous Case

import { Result } from '@praha/byethrow';

const result: Result.ResultMaybeAsync<number, string> = { type: 'Success', value: 10 };
@example

Asynchronous 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' });