FuncType - v0.9.5
    Preparing search index...

    Interface Extractable<T>

    Extractable type class for data structures that can extract their values with various fallback strategies.

    This interface is implemented by Option, Either, and other types that wrap values and need safe extraction methods.

    interface Extractable<T extends Type> {
        get(): T;
        getOrElse(defaultValue: T): T;
        getOrThrow(error?: Error): T;
        orElse(alternative: Extractable<T>): Extractable<T>;
        orNull(): null | T;
        orUndefined(): undefined | T;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Methods

    • Extracts the value unsafely

      Returns T

      The contained value

      Error if the container is empty

    • Returns the contained value or a default value

      Parameters

      • defaultValue: T

        The value to return if extraction fails

      Returns T

      The contained value or defaultValue

    • Returns the contained value or throws an error

      Parameters

      • Optionalerror: Error

        Optional error to throw (implementations may have defaults)

      Returns T

      The contained value

      The specified error if extraction fails

    • Returns this container if it has a value, otherwise returns the alternative

      Parameters

      Returns Extractable<T>

      This container or the alternative

    • Returns the contained value or null

      Returns null | T

      The contained value or null

    • Returns the contained value or undefined

      Returns undefined | T

      The contained value or undefined