Options
All
  • Public
  • Public/Protected
  • All
Menu

A type representing the result of a successful computation.

This type is not intended to be used or instantiated directly. Instead, Ok instances can be created with Result.ok and can then be manipulated with any method available on Result.

Please see the Result documentation for more information.

Note:

All Ok methods are documented at the Result level.

Type parameters

  • T

    The type of the value contained in this Ok instance.

Hierarchy

Index

Methods

flatMap

  • flatMap<E, U>(func: function): Result<U, E>

getErr

getOk

isErr

  • isErr(): boolean

isOk

  • isOk(): boolean

map

  • map<E, U>(func: function): Result<U, E>
  • Type parameters

    • E

    • U

    Parameters

    • func: function
        • (val: T): U
        • Parameters

          • val: T

          Returns U

    Returns Result<U, E>

mapErr

  • mapErr<E, F>(func: function): Result<T, F>
  • Type parameters

    • E

    • F

    Parameters

    • func: function
        • (val: E): F
        • Parameters

          • val: E

          Returns F

    Returns Result<T, F>

match

  • match<E, U, F>(options: ResultMatch<T, E, U, F>): U | F

orElse

  • orElse<E, F>(func: function): Result<T, F>

toString

  • toString(): string

unwrap

  • unwrap(message?: undefined | string): T

unwrapErr

  • unwrapErr<E>(message?: undefined | string): never

unwrapOr

  • unwrapOr(other: T): T

unwrapOrElse

  • unwrapOrElse<E>(func: function): T

Static err

  • err<F>(error: F): Result<any, F>
  • Creates an Err with the given value.

    const one = Result.err(1);
    // one.unwrapErr() === 1

    Type parameters

    • F

      The type of value that the new Err will contain.

    Parameters

    • error: F

      The value with which to create the Err instance.

    Returns Result<any, F>

    An Err instance containing value.

Static ok

  • ok<U>(value: U): Result<U, any>
  • Creates an Ok with the given value.

    const one = Result.ok(1);
    // one.unwrap() === 1

    Type parameters

    • U

      The type of value that the new Ok will contain.

    Parameters

    • value: U

      The value with which to create the Ok instance.

    Returns Result<U, any>

    An Ok instance containing value.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc