MVFv3 API Documentation
    Preparing search index...

    Type Parameters

    • T

    Implements

    • OkBase<T>
    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • value: T

      Returns Ok<T>

    Properties

    _tag: "Ok" = 'Ok'

    Accessors

    • get "[toStringTag]"(): string

      Returns string

    • get error(): null

      The error, if available.

      Returns null

    • get value(): T

      The good value, if available.

      Returns T

    Methods

    • Returns IterableIterator<T>

    • Returns the passed value if this is Ok, otherwise returns this.

      Type Parameters

      • U

      Parameters

      Returns Result<U, never>

    • Maps a Result<T, E> to Result<U, E | F> by applying a function to a contained Ok value, producing a new result.

      Type Parameters

      • U
      • F

      Parameters

      Returns Result<U, F>

    • Maps a Result<T, E> to Promise<Result<U, E | F>> by applying a function to a contained Ok value, producing a new async result.

      Type Parameters

      • U
      • F

      Parameters

      Returns Promise<Result<U, F>>

    • Returns an option of the inner error of a result.

      Returns Option<never>

    • Unwraps a result, yielding the value.

      USE THIS SPARINGLY! It is generally better to use unwrapOr or map to handle situations you may be temped to .expect() in.

      This is good for using in tests.

      Parameters

      • message: string

      Returns T

      A new error with the provided message, if the result is an Err.

    • Unwraps a result, yielding the error.

      USE THIS SPARINGLY! It is generally better to use unwrapOr or map to handle situations you may be temped to .expect() in.

      This is good for using in tests.

      Parameters

      • message: string

      Returns never

      A new error with the provided message, if the result is an Ok.

    • Allows inspection of the interior result value, if it is Ok. May be useful in cases where you do not want to modify the result.

      Parameters

      • fn: (value: T) => void

      Returns Ok<T>

    • Allows inspection of the interior error value, if it is Err. May be useful in cases where you do not want to modify the error.

      Returns Ok<T>

    • Asserts that the current result is Err.

      Returns this is Err<never>

    • Asserts that the current result is Err and the error passes the given predicate.

      Parameters

      • fn: (error: never) => boolean

      Returns this is Err<never>

    • Asserts that the current result is Ok.

      Returns this is Ok<T>

    • Asserts that the current result is Ok and the value passes the given predicate.

      Parameters

      • fn: (value: T) => boolean

      Returns this is Ok<T>

    • Returns IterableIterator<T>

    • Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving the Err value untouched.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => U

      Returns Ok<U>

    • Maps a Result<T, E> to Promise<Result<U, E>> by applying a function to a contained Ok value, leaving the Err value untouched.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => Promise<U>

      Returns Promise<Ok<U>>

    • Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving the Ok value untouched.

      Type Parameters

      • F

      Parameters

      • fn: (error: never) => F

      Returns Ok<T>

    • Maps a Result<T, E> to U by applying a function to a contained Ok value. If the result is an Err, the fallback value will be returned.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => U
      • fallback: U

      Returns U

    • Maps a Result<T, E> to Promise by applying a function to a contained Ok value. If the result is an Err, the fallback value will be returned.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => Promise<U>
      • fallback: U

      Returns Promise<U>

    • Maps a Result<T, E> to U by applying a function to a contained Ok value. If the result is an Err, the fallback function will be called and its result will be returned.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => U
      • fallback: () => U

      Returns U

    • Maps a Result<T, E> to Promise by applying a function to a contained Ok value. If the result is an Err, the fallback function will be called and its result will be returned.

      Type Parameters

      • U

      Parameters

      • fn: (value: T) => Promise<U>
      • fallback: () => Promise<U>

      Returns Promise<U>

    • Returns an option of the inner value of a result.

      Returns Option<T>

    • Returns the passed value if this is Err, otherwise returns this.

      Type Parameters

      • U = T
      • F = never

      Parameters

      Returns Ok<T>

    • Calls fn if the result is an Err, otherwise returns this.

      Type Parameters

      • U = T
      • F = never

      Parameters

      Returns Ok<T>

    • Returns a string representation of the result for debugging purposes.

      Returns string

    • Returns the inner value of a result, if it is Ok. Otherwise, the contained error will be thrown.

      USE THIS SPARINGLY! It is generally better to use unwrapOr or map to handle situations you may be temped to .unwrap() in.

      Returns T

      The contained error, if the result is an Err.

    • Returns the inner value of a result, if it is Ok. Otherwise, the provided fallback value will be returned.

      Type Parameters

      • V

      Parameters

      • fallback: T | V

      Returns T | V

    • Returns the inner value of a result, if it is Ok. Otherwise, the provided fallback funtion will be called and its result will be returned.

      Type Parameters

      • V

      Parameters

      • fn: (error: never) => T | V

      Returns T