logo
byethrow
Guide
API Reference
Guide
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()

#Type Alias: Result<T, E>

Result<T, E> = Success<T> | Failure<E>

Defined in: result.ts:68

A union type representing either a success or a failure.

#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 doSomething = (): Result.Result<number, string> => {
  return Math.random() > 0.5
    ? { type: 'Success', value: 10 }
    : { type: 'Failure', error: 'Oops' };
};

Last Updated:

Previous PageType Alias: InferSuccess\<T\>
Next PageType Alias: ResultAsync\<T, E\>