result2
    Preparing search index...

    Class Result<T, E>

    Type Parameters

    • T
    • E
    Index

    Constructors

    Methods

    • beware that it consumes the result

      Returns null | E

      contained Err value or null.

      panics if the result was already consumed

    • beware it consumes the result

      Parameters

      • msg: string

      Returns NonNullable<T>

      contained Ok.

      panics with custom message, or if the result was already consumed.

    • run some code on the Ok value (if no Err) without consuming or transforming the result.

      Type Parameters

      • F

      Parameters

      • fn: (okVal: Readonly<NonNullable<T>>) => F

        a pure function to be applied to the contained Ok

      Returns Result<T, E>

      the original result

      panics if the result was already consumed

    • run some code on the Err value (if no Ok) without consuming or transforming the result.

      Type Parameters

      • F

      Parameters

      • fn: (errVal: Readonly<NonNullable<E>>) => F

        a pure function to be applied to the contained Err

      Returns Result<T, E>

      the original result

      panics if the result was already consumed

    • Returns boolean

      if error occurred

      panics if the result was already consumed

    • Parameters

      • fn: (errValue: Readonly<undefined | NonNullable<E>>) => boolean

        a pure function to be applied once on the Err value

      Returns boolean

      false if Result was an Ok without executing the provided function or true if Result was Err and the provided function returns true when applied to the Err value

      panics if the result was already consumed

    • Returns boolean

      if no error occurred

      panics if the result was already consumed

    • Parameters

      • fn: (okVal: Readonly<NonNullable<T>>) => boolean

        a pure function to be applied once on the Ok value

      Returns boolean

      false if Result was an Err without executing the provided function or true if Result was Ok and the provided function returns true when applied to the Ok value

      panics if the result was already consumed

    • transform the Ok value without consumption

      Type Parameters

      • U

      Parameters

      • fn: (okVal: NonNullable<T>) => NonNullable<U>

        function to be applied on the contained Ok value

      Returns Result<U, E>

      the Result after applying the provided function to the contained Ok, leaving the Err untouched

      panics if the result was already consumed

    • transform the Err value without consumption

      Type Parameters

      • F

      Parameters

      • fn: (errValue: undefined | NonNullable<E>) => undefined | NonNullable<F>

        function to be applied on the contained Err value

      Returns Result<T, F>

      the Result after applying the provided function to the contained Err, leaving the Ok untouched

      panics if the result was already consumed

    • transforms the Ok value or returns the defaultVal if Err without consumption

      Type Parameters

      • U

      Parameters

      • defaultVal: U

        value to return if Result was Err

      • fn: (okVal: NonNullable<T>) => U

        function to be applied on the contained Ok value

      Returns U

      mapped Ok value or the default value

      panics if the result was already consumed

    • Type Parameters

      • U
      • F

      Parameters

      • OptionalokArm: (okVal: NonNullable<T>) => U

        a function to consume the Ok value

      • OptionalerrArm: (errVal: undefined | NonNullable<E>) => F

        a function to consume the Err value

      Returns void | U | F

      the return of okArm if it was Ok or the return of errArm

    • beware it consumes the result

      Returns null | T

      contained Ok value or null.

      panics if the result was already consumed.

    • Returns NonNullable<T>

      value wrapped in Ok

      panics if an error occurred, or the result was already consumed